display the characters for ASCII code

#include <iostream>
#include <conio>

int main()
{


for(int a = 0;a<8;a++)
{
cout <<endl;
for(int b = 0;b<17;b++)
{

cout<<static_cast<char>(a);
}
}
getch();
return 0 ;
}


This program is about display the characters for the ASCII codes.My problem is that i can only make the characters display for the numbers of 0 to 17.I want to make it cycle from ASCII code 0 to 127 and display each 16 characters per line.Any modification to the my source code ?
Small tip: Your cout should look like this: char(a*16+b)
Well some of those characters aren't printable while others such as CR, LF, Backspace, Tab, etc will scramble your output.

You should probably only attempt to print the character if isprint( ch ) returns non-zero, otherwise print a space.
Topic archived. No new replies allowed.