/* * Program to get and echo a line of text, converting lowercase * to uppercase. */ #include #include #include int main(void) { char line[80]; printf("enter a line of text\n"); fgets(line, sizeof line, stdin); char *nl = strchr(line, '\n'); if (nl == NULL) { printf("line too long\n"); return 1; } *nl = '\0'; printf("line:\n%s\n", line); for (char * p = line; *p != '\0'; ++p) { *p = toupper(*p); } printf("in all caps:\n%s\n", line); return 0; }