Hi, I would like to ask how am I going to display an ASCII character, especially the square (2) and square root symbol. These two character are in the ASCII table for 166 and 251 respectively. As I know, the code to show ASCII character is as below:
cout << (char)166;
However, this does not show anything during the output.
Is there any question with my code? Or any suggestion on how to display this character?
The reason those aren't showing is because they don't exist in the ASCII table at all.
ASCII only goes up to 127. Anything higher than that and you get into the extended code page (read: not ASCII). Which code page you get depends on your system/language settings and is unreliable unless you explicitly set it in your code. (And outputting anything but ASCII with iostream is unreliable anyway).
For this you're stepping outside what the standard libs can do, and you'll probably need to go to platform specific solutions. So basically it's more trouble than it's worth. Just stick to ASCII
- Figure out which code page is the one you want (I have no idea -- but if you can get it to output Unicode that's a catch-all)
- switch to it
- output codes over 127