Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added a ref to fio44

...

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 Markup
When using {{fgetpos()}} and {{fsetpos()}} it important to keep in mind \[[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.

...