Versions Compared

Key

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

...

Code Block
bgColor#ffcccc"
/* program code */
char const *old = "oldfile.ext";
char const *new = "newfile.ext";
if (rename(old, new) != 0) {
  /* Handle rename failure */
}
/* program code */

...

Code Block
bgColor#ccccff"
/* program code */
char const *old = "oldfile.ext";
char const *new = "newfile.ext";
FILE *file = fopen(new, "r");

if (file != NULL) {
  fclose(file);
  if (rename(old, new) != 0) {
    /* Handle remove failure */
  }
}
else {
  /* handle error condition */
}
/* program code */

...