{{keywords>wiki library source code example reference}} ====== rename ====== int rename(const char *old_filename, const char *new_filename); Changes name of file oldname to newname. Returns non-zero on failure. ===== Example Source ===== /* * rename example code * http://code-reference.com/c/stdio.h/rename */ #include /* including standard library */ //#include /* uncomment this for Windows */ #define FILENAME "test_tmp.txt" int main ( void ) { FILE *tmpfile; char string[20]; tmpfile = fopen(FILENAME, "w"); if (tmpfile == 0 ) { perror("cannot open file"); } fprintf (tmpfile, "temporary file for c remove example\n"); fclose(tmpfile); rename (FILENAME,"test_new.txt"); return 0; } ==== output ==== ./rename file will be created write text into file "temporary file for c rename example" file will be renamed into test_new.txt