ASCII Table

yup i am seriuos,

the following is a C++ code that will give you the ASCII table from 0 to 255:

#include <iostream>
#include <iomanip>

using namespace std;

int main( int ac, char ** av)
{
int i;
cout << “ASCII TABLE” << endl;
for( i=0; i<256; i++)
{
cout << ” int [” << dec << ((int) i) << “]”;
cout << ” hex [” << hex << ((int) i) << “]” << ” = [“;
if( i != 27 )
{
cout << ((char) i);
}
else
{
cout << “the escape character!”;
}
cout << “]” << endl;
}
return 0;
}

if you want more characters just change i<256 to i<‘number’ and it should work

the reason why i dug into this is because i wanted to try drawing with C++ using ASCII characters, and when i got the tables of the internet the numbers didn’t match the wanted characters, so making a table in C++ will give you the exact character, which saves the time wasted on calculating the right number of that wanted character ^_^

13 thoughts on “ASCII Table

  1. Alslam 3lykom,

    i suffered from the same problem when i started out with C. one thing you should keep in mind when dealing with the extended character set (over 127), the character set might not be available in every environment your program would run in .

    man it’s great to see another c/c++ programmer here. if this keeps up, we’ll outnumber the vb guys here 🙂

    keep up the good work

  2. Oh yeah VB!! I used to be one, but I have just started learning C -THANK GOD- (hoping i’ll the ugliest/stupidest language, that’s what i think of it). I’m not saying it’s not easy, moreover i can grantee you that any normal 10 years old kid could program in it(that’s the special thing about it), but at the same time it’s DUM!!
    that’s my opinion

    Oh yeah, welcome slartibarfaster to this blog!

  3. Hah! Kids! What happened to good ol’ COBOL and RPG? These are what I grew up learning! If those 2 languages can’t do it, then it can’t be done. 😀

    Ug, the memories are painful.

  4. COBOL looks pretty neat and easy, i should read more about it, but RPG looks a tiny bit complicated and if what i understood was true it is then somehow stupid 😛

    and hey you can’t blame me for being born withing this generation 😛

  5. LoL. I was messing with you. I’m only 25. Seriously though, I did have to learn COBOL and RPG, but that is only because there are alot of manufacturing plants in the southern US where I grew up.

    Personally, I focused more on PHP and ASP.NET due to my concentration in college, but now I don’t ever get to program anything. Never get a career! It will kill your dreams!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.