ASCII columns

Nov 30, 2016 at 4:47pm
I have this code that outputs ASCII code in columuns. But the order of the numbers comes in rows, 32 34 35 36 37 38 39 40 41 42 43 44 45 46 47 etc. But I want it to output the same numbers but vertical, liket this.
32
33
34
35
etc.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>   // cout
#include <iomanip>    // setw

using namespace std;
int main ()
{
    int a;                                                                    
    for(a=32;a<=255;++a)                                                      
    {
        cout << a << setw(2) << static_cast<char>(a) << setw(20); 
    }
    return 0;
}
Nov 30, 2016 at 5:50pm
Just modify line 10 to insert an endl character.
Nov 30, 2016 at 6:55pm
What do you mean by that?
Nov 30, 2016 at 8:53pm
1
2
3

 cout << a << setw( 2 ) << static_cast<char>( a ) << setw( 20 ) << endl; 
Topic archived. No new replies allowed.