资源简介
包含可运行cpp源码和5页说明书,欢迎下载参考.............................................................................................................................................................................................................
代码片段和文件信息
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
void pwd();
void dir();
void cd();
void deldir();
void copy();
int main(int argc char *argv[])
{
cout<<“>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>“< cout<<“1. mypwd “< cout<<“2. mydir “< cout<<“3. mycd “< cout<<“4. mydel “< cout<<“5. mycopy “< cout<<“6. exit “<
string str;
while(str != “exit“) {
cout<<“[jianfeifan@]$“;
cin>>str;
if(str == “mypwd“){
pwd();
}
if(str == “mydir“) {
dir();
}
if(str == “mycd“) {
cd();
}
if(str == “mycopy“){
copy();
}
if(str == “mydel“){
deldir();
}
}
return 0;
}
void pwd()
{
char ptr[80];
getcwd(ptrsizeof(ptr));
cout< }
void dir()
{
DIR *dirp;
int i=0;
struct dirent *dp;
dirp = opendir(“. “);
while ((dp = readdir(dirp)) != NULL) {
printf(“%s “ dp->d_name );
i++;
if(i%5==0)
{
printf(“\n“);
}
}
printf(“\n“);
(void) closedir(dirp);
}
void cd()
{
char dirname[20];
cin>>dirname;
if(chdir(dirname) == -1)
{
cout<<“the directory is not exit!!!“<
}
else
{
cout<<“change directory success!!!“< }
}
void copy()
{
char buffer[1024];
FILE *in*out;
int len;
char dirname1[20]dirname2[20];
cin>>dirname1;cin>>dirname2;
if((in=fopen(dirname1“r“))==NULL)
{
printf(“the file1 can not open\n“);
exit(1);
}
if((out=fopen(dirname2“w“))==NULL)
{
printf(“the new file can not open\n“);
exit(1);
}
while((len=fread(buffer11024in))>0)
{
fwrite(buffer1lenout);
memset(buffer01024);
}
fclose(out);
fclose(in);
}
void deldir()
{
char filename[20];
cin >> filename;
if(rmdir(filename) == 0)
{
cout< }
else
cout< }
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 46635 2017-09-12 15:28 说明书.docx
文件 2476 2017-09-07 16:22 Test.cpp
- 上一篇:凌哥CC攻击器.zip
- 下一篇:NI软件卸载,修复工具
评论
共有 条评论