• Welcome to Valhalla Legends Archive.
 

Character values in C++

Started by TruffleShuffle, May 07, 2003, 08:40 AM

Previous topic - Next topic

TruffleShuffle

Whats the equiv. of chr() from VB, in C++ ?

Yoni

Just cast the number to a char, or simply assign it to a char.

The type char in C/C++ is actually an 8-bit integer. You may cast between different integer types freely.

Example:
char escape = 27;
char fakespace = 160;

Etc...

iago

If you're using a string, don't forget to dereference it, though.
char *str = "iago is da bomb!";
char FirstLetter = *str;
-or-
char ThirdLetter = str[2];

This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*