Valhalla Legends Archive

Programming => General Programming => Topic started by: TruffleShuffle on May 07, 2003, 08:40 AM

Title: Character values in C++
Post by: TruffleShuffle on May 07, 2003, 08:40 AM
Whats the equiv. of chr() from VB, in C++ ?
Title: Re:Character values in C++
Post by: Yoni on May 07, 2003, 10:23 AM
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...
Title: Re:Character values in C++
Post by: iago on May 08, 2003, 03:16 AM
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];