给文件或者文件夹改名

比如把  E:\正则.txt 改成 E:\正则.c
#include <stdio.h> 

int main(void)
{
char oldname[80], newname[80];

/* prompt for file to rename and new name */
printf(
"File to rename: ");
gets(oldname);
printf(
"New name: ");
gets(newname);

/* Rename the file */
if (rename(oldname, newname) == 0)
printf(
"Renamed %s to %s.\n", oldname, newname);
else
perror(
"rename");

return 0;
}

posted on 2011-09-17 19:54  原来...  阅读(361)  评论(0编辑  收藏  举报

导航