Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ffcccc
langc
char buf[BUFSIZ];
#include <stdio.h>
 
void func(FILE *file;) {
/* Initialize file */char buf[BUFSIZ];

  if (fgets(buf, sizeof(buf), file) == NULL) {
    /* Set error flag and continue. */
  }

}

However, buf is not reset and has unknown contents.

...

Code Block
bgColor#ccccff
langc
char buf[BUFSIZ];
#include <stdio.h>
 
void func(FILE *file;) {
/* Initialize file */char buf[BUFSIZ];

  if (fgets(buf, sizeof(buf), file) == NULL) {
    /* Set error flag and continue. */
    *buf = '\0';
  }

}

Exceptions

FIO40-EX1: If the string goes out of scope immediately following the call to fgets() or fgetws() or is not referenced in the case of a failure, it need not be reset.

...