This line doesn’t do the right thing:
ch += 32*j;
You want to count by 32, that’s either
ch += 32;
or
ch = i + 32*j;
I strongly recommend making the numeric and character values match during your output. So change
cout << setw(3) << i+(32*j) << " " << setw(6) << ch;
to
cout << setw(3) << int(ch) << " " << setw(6) << ch;
Related Posts:
- std::string to char*
- Conversion from string to char – c++
- What is an unsigned char?
- How to read a file line by line or a whole text file at once?
- How to convert a char array to a string?
- finding dll for “The specified module could not be found”
- Convert an int to ASCII character
- How can I clear console
- How to go from fopen to fopen_s
- undefined reference to WinMain@16 (codeblocks)
- “X does not name a type” error in C++
- ‘cout’ was not declared in this scope
- Windows 7 exception code: 0xc0000409
- Difference between ‘strcpy’ and ‘strcpy_s’?
- make: g++: Command not found
- streambuf::xsgetn and state flags
- ‘cout’ was not declared in this scope
- How to convert a single char into an int [duplicate]
- std::string to char*
- VC++ fatal error LNK1168: cannot open filename.exe for writing
- How to convert a std::string to const char* or char*
- Why would we call cin.clear() and cin.ignore() after reading input?
- getline() does not work if used after some inputs
- MinGW: “gcc is not recognized as an internal or external command”
- Reading from text file until EOF repeats last line
- How can I convert const char* to string and then back to char*?
- LNK1168: cannot open debug\file.exe for writing
- Convert char* to string C++
- VC++ fatal error LNK1168: cannot open filename.exe for writing
- How do I add the MinGW bin directory to my system path?
- Run C++ in command prompt – Windows
- How to get Current Directory?
- Cannot open Windows.h in Microsoft Visual Studio
- How to convert ASCII value into char in C++?
- The program can’t start because libgcc_s_dw2-1.dll is missing
- Is there a replacement for unistd.h for Windows (Visual C)?
- Comparing the values of char arrays in C++
- Convert char array to single int?
- cin.eof() functionality
- CMake : C and CXX compiler identification is unknown Win10 CMakeGUI
- How to sort with a lambda?
- Converting string to ASCII
- The difference between cin.ignore and cin.sync
- casting int to char using C++ style casting
- How to print (using cout) a number in binary form?
- What is the source of the data for the ProgramFiles, ProgramW6432Dir, ProgramFilesDir (x86), CommonProgramFiles environment variables?
- LPCSTR, LPCTSTR and LPTSTR
- Xcode 11.1: iostream’ file not found
- What’s the difference between while(cin) and while(cin >> num)
- operator << must take exactly one argument
- C++ 2d char array to string
- Using cin for char array
- How do I simply compare characters in C++?
- Using cin to input a single letter into a char
- REGSVR32: the module “xxxxx.dll” failed to load … dependent assembly could not be found
- How to solve “Unresolved inclusion:
” in a C++ file in Eclipse CDT? - Is “delete this” allowed in C++?
- What is a segmentation fault?
- How many spaces for tab character(\t)?
- How to create a dynamic array of integers
- How to create a dynamic array of integers
- Linker Error C++ “undefined reference ” [duplicate]
- How do I build a graphical user interface in C++? [closed]
- C++ convert from 1 char to string?
- How do I build a graphical user interface in C++? [closed]
- convert a char* to std::string
- system(“pause”); – Why is it wrong?
- Pause Console in C++ program
- system(“pause”); – Why is it wrong?
- Pause Console in C++ program
- How to implement 2D vector array?
- Why the switch statement cannot be applied on strings?
- What is the difference between g++ and gcc?
- How to use setprecision in C++
- How to dynamically allocate arrays in C++
- What does (~0L) mean?
- How to dynamically allocate arrays in C++
- What is the best way to use a HashMap in C++?
- What is the best way to use a HashMap in C++?
- What are the differences between a pointer variable and a reference variable in C++?
- What is an undefined reference/unresolved external symbol error and how do I fix it?
- Sleep for milliseconds
- How to convert string to char array in C++?
- How can I convert a std::string to int?
- Easiest way to convert int to string in C++
- What is the difference between float and double?
- Why is “using namespace std;” considered bad practice?
- What is the easiest way to initialize a std::vector with hardcoded elements?
- What is a lambda expression in C++11?
- Vector of Vectors to create matrix
- How to throw a C++ exception
- How to generate a random number in C++?
- pinpointing “conditional jump or move depends on uninitialized value(s)” valgrind message
- What is an undefined reference/unresolved external symbol error and how do I fix it?
- How do I find the length of an array?
- Sleep for milliseconds
- How to convert string to char array in C++?
- C++ — expected primary-expression before ‘ ‘
- Using getline() with file input in C++
- What is the effect of extern “C” in C++?