strange unsigned char's- questions

Hello :)

Was looking at the 255 unsigned char's in vc++
using the code below.

got a few questions 'bout some chars (... is to see the spaces etc):

number 7: output "7 equals ..." , is it possable that this one is nothing ?

number 13: output "... equals" , what did this one do ? counter output got deleted and replaced by the ch output?

number 32 and 255: output "32 equals ..." and "255 equals ...", are both of them spaces or is there some difference between them?


Hope I'll get some answers :)

tx on advance


#include <iostream>
#include <cstdlib>
using namespace std;

void exit ()
{
	cout << "\n\nPress enter to exit \n";
	cin.get();
}

int main ()
{
	unsigned char ch;
	int counter;
	
	ch = 1;
	counter = 1;
	while (ch)
	{
		cout << counter << " equals "<< ch << "...\n";
		ch++;
		counter++;
	}
	
	
	exit ();
	return 0;
}
Last edited on
http://www.cplusplus.com/doc/ascii/
The standard ASCII table defines 128 character codes (from 0 to 127), of which, the first 32 are control codes (non-printable), and the remaining 96 character codes are representable characters

character 13 ( '\r' ) makes the cursor go at the beginning of the line
Well , you answered one of questions:) (tx for that ^^)

but as far as I read the link you gave me, it didn't explain what control code 7 does and the difference between number 32 and 255

(aah btw ,seems like unsigned char's aren't the same as ASCII, cause i get 255 chars)
Character 7 is the bell http://en.wikipedia.org/wiki/Bell_character
Read the article to know about characters 128-255
Tx , never would have though 'bout it that a char would be linked with sound. Might come handy later :)

Well, mind answering the last question aswell then ?
difference between char 32 and 255? ^^
Bazzy, you say that the first 32 characters are non-printable, so why can I write a program that outputs them? The first few characters looked like faces.
Because the Windows console interprets them as weird characters.
On some terminals you may get a tiny number displaying the actual hex value or the name of the character
Topic archived. No new replies allowed.