C: correct usage of strtok_r

The documentation for strtok_r is quite clear. The strtok_r() function is a reentrant version strtok(). The saveptr argument is a pointer to a char * variable that is used internally by strtok_r() in order to maintain context between successive calls that parse the same string. On the first call to strtok_r(), str should point to the string … Read more

Convert int to char in java

will print out the char with Unicode code point 1 (start-of-heading char, which isn’t printable; see this table: C0 Controls and Basic Latin, same as ASCII) will print out the char with Unicode code point 49 (one corresponding to ‘1’) If you want to convert a digit (0-9), you can add 48 to it and cast, or something … Read more

char *array and char array[]

The declaration and initialization declares a pointer array and make it point to a constant array of 31 characters. The declaration and initialization declares an array of characters, containing 31 characters. And yes, the size of the arrays is 31, as it includes the terminating ‘\0’ character. Laid out in memory, it will be something like this for the … Read more

What is an unsigned char?

In C++, there are three distinct character types: char signed char unsigned char If you are using character types for text, use the unqualified char: it is the type of character literals like ‘a’ or ‘0’ (in C++ only, in C their type is int) it is the type that makes up C strings like … Read more