
命令格式:mv
[-fiv] source destination
参数说明:
-f:force,强制直接移动而不询问
-i:若目标文件(destination)已经存在,就会询问是否覆盖
-u:若目标文件已经存在,且源文件比较新,才会更新案例:将/test1目录下的file1复制到/test3目录,并将文件名改为file2,可输入以下命令:
mv /test1/file1 /test3/file2
#includevoid
FileCopy()
{
FILE
*oldfile,
*newfile
oldfile
=
fopen("oldfilename",
"r")//打开源文件
newfile
=
fopen("newfile",
"w")//打开目标文件
if(!oldfile
&&
!newfile)//打开成功
{
byte
buff
while(!feof(oldfile))
{//从源文件读取一个字节,并写到目标文件
fread(&buff1,
1,
1,
oldfile)
fwrite(&buff1,
1,
1,
newfile)
}
}
if(oldfile)
fclose(oldfile)
if(newfile)
fclose(newfile)
}
先给你列出stu2主目录的文件信息这个功能的功能代码:#include
<unistd.h>
#include
<dirent.h>
#include
<stdlib.h>
#include
<stdio.h>
void
read_dir()///==ls
{
char
buf[255]
buf=“你的stu2目录的绝对路径”;
dir
*dirp
struct
dirent
*direntp
dirp
=
opendir(buf)
if(
dirp
!=
null
)
{
for()
{
direntp
=
readdir(
dirp
)
if(
direntp
==
null
)
break
if(dt_dir
==
direntp->d_type)
printf(
"%s,%s",direntp->d_name,"
"
)
}
printf("\n")
closedir(
dirp
)
}
}
然后在你主函数里面调用一下试试。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)