...
This noncompliant code example attempts to remove the trailing newline (\n) from an input line.:
| Code Block | ||||
|---|---|---|---|---|
| ||||
char buf[BUFSIZ + 1];
if (fgets(buf, sizeof(buf), stdin)) {
if (*buf) { /* see FIO37-C */
buf[strlen(buf) - 1] = '\0';
}
}
else {
/* Handle error condition */
}
|
...