Let's say you have:
const char * something = "m";
How would one make this uppercase, using toupper (or something else, if applicable)?
I want to use a char *
instead of a string
(I can use a string, but then I have to use str.c_str()
).
So, how can I make char * something = "m";
contain "M"
?
I find you choice of C strings disturbing.. but anyway.
You can't change a string literal (char *something
). Try an array:
char something[] = "m";
something[0] = toupper(something[0]);
To change an entire string:
char something[] = "hello";
char *p = something;
while (*p) {
*p = toupper(*p);
p++;
}