Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Spacing change

...

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

  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
#include <stdio.h>
 
#define BUFFER_SIZE 1024
void func(FILE *file) {
  char buf[BUFFER_SIZE];

  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.

...