/* * Program to get and echo line of text using fgets(). */ #include #include #define SIZE 80 int main(void) { printf("enter line\n"); char line[SIZE]; fgets(line, SIZE, stdin); /* was the line too long? */ char *endline = strchr(line, '\n'); if (endline == NULL) { printf("line too long\n"); } else { *endline = '\0'; printf("line is '%s'\n", line); } return 0; }