How to convert ASCII string to ASCII values C++

1 Answer

0 votes
#include <iostream>

int main()
{
    std::string s = "c++"; 
    const char *arr = s.c_str(); 
 
    for (int i = 0; arr[i] != '\0'; i++) { 
        std::cout << (int)arr[i] << " "; 
    } 

   return 0;
}



/*
run:

99 43 43 

*/

 



answered Aug 2, 2020 by avibootz

Related questions

1 answer 210 views
1 answer 188 views
1 answer 85 views
85 views asked Nov 18, 2024 by avibootz
2 answers 190 views
1 answer 160 views
...