ch3-Charlist (List all 256 ASCII characters)
Chapter_3 Exercise_3-1 Guess | Exercise_3-2 |
Charlist.cpp TCP1, p. 132 download
#include <iostream>
using std::cout;
using std::endl;
// Display all 256 ASCII characters
int main()
{
for(int i = 0; i < 256; i++)
{
cout << "char(" << i << "): '"
<< char(i) // Type conversion
<< "'" << endl;
}
return 0;
}
/*
g++ Charlist.cpp -o Charlist
./Charlist > out.txt // save result to file
*/
Notes:
See the ASCII_code.
Do not type the comments in the terminal window. For instance, type:
./Charlist > out.txt
Here, `>' redirects the output to a file.
Chapter_3 Exercise_3-1 Guess | BACK_TO_TOP | Exercise_3-2 |
Comments
Post a Comment