紀錄C當中,一個簡單的改檔名function,rename();
#include <stdio.h>
int main () {
int ret;
char oldname[] = "file.txt";
char newname[] = "newfile.txt";
ret = rename(oldname, newname);
if(ret == 0) {
printf("renamed successfully");
} else {
printf("unable to rename");
}
return 0;
}
網誌管理員已經移除這則留言。
回覆刪除