outputting ascii table in C++

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;

Leave a Comment