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("te mp","w");
while ((c = fgetc (alfa)) != EOF)
fputc(c,tempf);
fclose (tempf);
fclose(alfa);
remove (name);
tempf=fopen("te mp","r");
vita=fopen(name 2,"w");
while ((c = fgetc (tempf)) != EOF)
fputc(c,vita);
fclose (tempf);
remove ("temp");
fclose (vita);
return 0;
}
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("te mp","w");
while ((c = fgetc (alfa)) != EOF)
fputc(c,tempf);
fclose (tempf);
fclose(alfa);
remove (name);
tempf=fopen("te mp","r");
vita=fopen(name 2,"w");
while ((c = fgetc (tempf)) != EOF)
fputc(c,vita);
fclose (tempf);
remove ("temp");
fclose (vita);
return 0;
}
Comment