ASCII problem

Hey guys, (I'm french so I'm sorry for my bad english)

I'm trying to do a loop that will display the characters for the ASCII codes 0 through 127. My problem is not with the loop, I understand how it works. I just need to know how to convert a number (my variable being incremented) into its ASCII character to display it on the screen.

I found it easy to do character -> number but now I need to display the characters and I need to do number -> character.

Can someone help me?
Just convert the number to a character, either by storing it in a char variable or by using a cast, e.g.:
for (int i=0;i<=127;i++)cout << static_cast<char>(i);
Thanks for your reply!

Can you explain how static_cast<>() works please? And do I need to include something (header) ? Just to be sure :)
No, static_cast doesn't need any headers, it's a builtin operator in C++.
See here for an explanation:
http://msdn.microsoft.com/en-us/library/c36yw7x9%28v=vs.80%29.aspx
Thank you very much, I can finish my program now :)
Topic archived. No new replies allowed.