How to rename a file in C

1 Answer

0 votes
#include <stdio.h>
 
int main()
{
    char file[100] = "d:\\data.txt";
    char newfile[100] = "d:\\newdata.txt";
	
    if (rename(file, newfile) == 0) {
        printf("File renamed ok\n");
    }
    else {
        printf("File renamed error\n");
    }
	
    return 0;
}
         
           
           
           
/*
run:
           
File renamed ok
        
*/

 



answered Jul 12, 2020 by avibootz

Related questions

1 answer 182 views
182 views asked Aug 25, 2015 by avibootz
1 answer 208 views
208 views asked Jun 9, 2018 by avibootz
1 answer 130 views
130 views asked Aug 22, 2023 by avibootz
1 answer 222 views
222 views asked Mar 10, 2020 by avibootz
1 answer 240 views
1 answer 215 views
215 views asked Aug 26, 2015 by avibootz
2 answers 291 views
291 views asked Aug 26, 2015 by avibootz
...