ahmed0saber

Rename or/and Change location of a file in C

Nov 4th, 2020
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.25 KB | None | 0 0
  1. #include <cstdio>
  2. using namespace std;
  3. int main()
  4. {
  5.     char oldname[] = "ab.txt";
  6.     char newname[] = "as.txt";
  7.    
  8.     if (rename(oldname, newname) != 0)
  9.         perror("Error renaming file");
  10.     else
  11.         printf("File renamed successfully");
  12.    
  13.     return 0;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment