On Mon, Jun 15, 2015 at 12:27 PM, Wolfgang Corcoran-Mathe <[email protected]> wrote: > emg's FIXME about nulls still applies. > > /* throw away rest of line */ > - while (fgets(buf, sizeof(buf), stdin) && *buf && buf[strlen(buf) - 1] > == '\n') > + while ((c = fgetc(stdin)) != '\n' && c != EOF) > /* FIXME: what if the first character of the rest of the line > is a null > - * byte? probably shouldn't juse fgets() */ > + * byte? */ > ;
Nope, not a problem anymore as you're explicitly checking against '\n' and EOF so reading a '\0' is fine. Much better than the fgets. -emg
