資料檔案——之重新命名或刪除檔案
阿新 • • 發佈:2020-11-28
程式碼:
1 //This is c program code! 2 /* *=+=+=+=+* *** *=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= 3 * 文件資訊: *** :~/WORKM/stutyCode/cCode/recipesProblemSolution/chapter06/test6_15.c 4 * 版權宣告: *** :(魎魍魅魑)MIT 5 * 聯絡信箱: *** :[email protected] 6 * 建立時間: *** :2020年11月21日的下午07:31 7 * 文件用途: *** :資料結構與演算法分析-c語言描述 8 * 作者資訊: *** :guochaoxxl(http://cnblogs.com/guochaoxxl) 9 * 修訂時間: *** :2020年第46周 11月21日 星期六 下午07:31 (第326天) 10 * 檔案描述: *** :自行新增 11 * *+=+=+=+=* *** *+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+*/ 12 #include <stdio.h> 13 14 int main(int argc, char **argv) 15 { 16 char ch; 17 printf("please select operation: r or d:"); 18 scanf("%c", &ch); 19 int tmp = getchar(); 20 if(ch == 'r'){ 21 int ren = rename("kolkata.txt", "city.dat"); 22 if(0 == ren){ 23 puts("Operation of renaming a file is successful."); 24 }else{ 25 puts("Operation of renaming a file is failed!"); 26 } 27 } 28 29 if(ch == 'd'){ 30 int rem = remove("city.dat"); 31 if(0 == rem){ 32 puts("Operation of deletion a file is successful."); 33 }else{ 34 puts("Operation of deletion a file is failed!"); 35 } 36 } 37 38 return 0; 39 }