What is the meaning of (char)0.
For example what does this mean?
array[1] = (char)0;
It's a C-style cast. That is, it converts 0 (which is a literal of type int) to char (the \0 character). That cast could have been avoided entirely by simply using the '\0' literal.
int to a char, but using a cast instead of just a litteral seems overkill - Etienne de Martel 2012-04-04 02:52
'\0' instead of (char)0. And if line is std::string, then use operator[] instead of at() if you're sure you'll never go out of bounds - Etienne de Martel 2012-04-04 02:57
'\0' is a character literal constant that is the null character (0 in ASCII) - Etienne de Martel 2012-04-04 03:04
It's 0 casted to a char, which is '\0'.
You are casting an int (integer) (0) to a character (char).
Casting means you are changing the type.