C - String Case Converting


The toupper() function converts from lowercase to uppercase, and the tolower() function does the reverse.

You can therefore convert a string to uppercase using this statement:

for(int i = 0 ; (buf[i] = (char)toupper(buf[i])) != '\0' ; ++i);

This loop will convert the entire string in the buf array to uppercase.

The loop stops when it reaches the string termination character '\0'.