C++ asci converter

I have this code which converts characters to asci\
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <iomanip>
int main()
{
  char word[32];
  std::cout<<"Please enter a word (maximum 32 characters): ";
  std::cin>> std::setw ( sizeof word ) >> word;
  std::cout<<"The integer values for this word are:\n";
  for ( int x = 0; word[x] != '\0'; x++ ) {
    std::cout<< word[x] <<" = "<< int ( word[x] ) <<'\n';
    
  }
        system("pause"); 
    return 0; 
}

how could i make one that also reads asci and gives me characters? Also how could i "Encrypt" it by multypling each value by 10. Then to read dividing by 10?
-Thanks
Cast the ASCII value.

std::cout << char(65);

Output:
A

A char can hold values from -128 to 127 so it isn't advisable to try to do too much math with one.
Last edited on
Topic archived. No new replies allowed.