On this page
rename
Prev: remove | Up: stdio.h | Next: setvbuf
Rel: stdio.h, stdio.h & File I/O Guide
Ref: cppreference — rename
Tags: #public #prog #c #stdlib #stdio #tier/standard
Include
#include <stdio.h>
Signature & Overview
int rename(const char *old_path, const char *new_path);
Renames or moves a file atomically within the same filesystem; returns 0 on success.
Notes & Pitfalls
- Atomic on POSIX within the same filesystem: On Windows,
rename()may fail if the destination already exists.
Example
#include <stdio.h>
int main(void) {
// Atomic replace pattern: write temp file -> fclose() -> rename(tmp, dst)
(void)rename;
}
Linked from
Related notes
- tuts/c/stdlib/stdio/remove Linked here; links to this page; shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/setvbuf Linked here; links to this page; shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio Linked here; links to this page; shared tags: #c, #prog, #stdio, #stdlib
- tuts/c/stdlib/stdio_and_file_io Linked here; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/stdio/fclose shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/feof shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/ferror shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/fflush shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/fgets shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/fopen shared tags: #c, #prog, #stdio, #stdlib, #tier