Upper Case
Completed
Read a line and print it in upper case using toupper in a loop.
Input
One line.
Output
One line.
Example
Input
Hello, World!
Output
HELLO, WORLD!
Editor
C
Hints
Loop until the '\0' and change each character in place.
Solution explanation
C strings in arrays can be modified character by character.
Show solution
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main() {
char s[200];
fgets(s, 200, stdin);
s[strcspn(s, "\n")] = '\0';
for (int i = 0; s[i] != '\0'; i++) {
s[i] = toupper(s[i]);
}
printf("%s\n", s);
return 0;
}