...
Code Block | ||
---|---|---|
| ||
char buf[BUFSIZBUFFERSIZE]; int ch; char *p; if (fgets(buf, sizeof(buf), stdin)) { /* fgets succeeds, scan for newline character */ p = strchr(buf, '\n'); if (p) { *p = '\0'; } else { /* newline not found, flush stdin to end of line */ while (((ch = getchar()) != '\n') && !feof(stdin) && !ferror(stdin) ); } } else { /* fgets failed, handle error */ } |
...
Code Block | ||
---|---|---|
| ||
char buf[BUFSIZBUFFERSIZE]; if (gets_s(buf, sizeof(buf)) == NULL) { /* handle error */ } |
...