+ 1

How do you change a char or string to from lower case to upper case and vice versa? C++

I was wondering how I can take a string like "text" and convert it to "TEXT". Also, how can I take same string and change the case of a specific char? I'm thinking of creating a for loop to iterate through each character of a string and set/change the case, but I'm not really sure how to go about doing so. Any help would be appreciated.

12th Sep 2017, 1:25 AM
Adam
Adam - avatar
3 odpowiedzi
0
#include <stdio.h> #include <ctype.h> toupper( Your_Char_Variable ); tolower( Your_Char_Variable ); if in string , try using somewhat like : char c = stringg[0] putchar( toupper( c ) ); stringg[0] = c; *I dunno your code* String is Array_of_Char. for "Extreme Logic" way , convert char to ascii , then manipulate with adding / deducting ascii , then put back to char.
12th Sep 2017, 1:48 AM
Mikhael Anthony
Mikhael Anthony - avatar