Versions Compared

Key

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

...

Code Block
bgColor#ccccff
FILE* fptr = fopen(file_name, "rb");
fpos_t pos;

if (fptr == NULL) {
  /* Handle Error */
}

/* Read data */

if (fgetpos(fptr, &pos)) {
  /* Handle Error */
}

/* Read the data that will be "pushed back" */

if (fsetpos(fptr, &pos)) {
  /* Handle Error */
}

/* Continue on */

Wiki MarkupWhen using {{Remember to always call fgetpos()}} and {{ before fsetpos()}} it important to keep in mind \[[ (see FIO44-C. Only use values for fsetpos() that are returned from fgetpos())]\].

Risk Assessment

If used improperly, ungetc() can cause data to be truncated or lost.

...