问题描述
您好我必须在C中创建一个项目,它将使C中的MS DOS移动命令
i已经完成了这个并且这会复制文件但是我不能使代码粘贴它也可以......有人可以帮我吗?
#include< stdio.h>
#include< string.h>
int main(int argc,char * argv []){
FILE * alfa;
FILE * tempf;
FILE * vita;
char c,name [15],name2 [15];
int i = 0;
if(argc< 3){
printf(" \\\
\ n");
返回1;
}
strcpy(name,argv [1]);
strcpy(name2,argv [2]);
while(name [i]!=''\'''){
if(name [i] ==''_''){
name [i] ='''';
i ++;
}
else {
name [i] = name [i];
i ++;
}
}
i = 0;
而(name2 [i]!=''\'''){
if(name2 [i] ==''_''){
name2 [i] ='''';
i ++;
}
else {
name2 [i] = name2 [i];
i ++;
}
}
alfa = fopen(name," r");
>
tempf = fopen(temp,w);
while((c = fgetc(alfa))!= EOF)
fputc(c,tempf);
fclose(tempf);
fclose(alfa);
删除(姓名);
tempf = fopen(" temp"," r");
vita = fopen(name2," ; w");
while((c = fgetc(tempf))!= EOF)
fputc(c,vita);
fclose(tempf);
删除(" temp");
fclose(vita);
返回0;
}
Hello i have to make a project in C that will make MS DOS move command in C
i have done this and this does copy the file but i cant make a code to paste it too...can someone hlp me?
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[] ){
FILE *alfa;
FILE *tempf;
FILE *vita;
char c, name[15], name2[15];
int i=0;
if (argc<3){
printf ("\n \n");
return 1;
}
strcpy(name, argv[1]);
strcpy(name2, argv[2]);
while (name[i]!=''\0''){
if (name[i]==''_''){
name[i]='' '';
i++;
}
else{
name[i]=name[i];
i++;
}
}
i=0;
while (name2[i]!=''\0''){
if (name2[i]==''_''){
name2[i]='' '';
i++;
}
else{
name2[i]=name2[i];
i++;
}
}
alfa=fopen(name,"r");
tempf=fopen("temp","w");
while ((c = fgetc (alfa)) != EOF)
fputc(c,tempf);
fclose (tempf);
fclose(alfa);
remove (name);
tempf=fopen("temp","r");
vita=fopen(name2,"w");
while ((c = fgetc (tempf)) != EOF)
fputc(c,vita);
fclose (tempf);
remove ("temp");
fclose (vita);
return 0;
}
这篇关于C项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!