I made some changes and experimented, but it's still not working. I've tried to put the entire path "C:\Program Files\File Mananger\File.txt" in quotes, and without (thanks for the idea robwhit), but neither way seems to affect it.
Code:
/* declare variables */
char original_file[256];
//char duplicate_file[256] = "\"C:\\Program Files\\File Manager\\";
char duplicate_file[256] = "C:\\Program Files\\File Mananger\\";
FILE *org,*dup;
char ch;
/* gather the file's name */
printf("Enter the name of the original file: ");
scanf("%255s",&original_file);
fflush(stdin);
if(strlen(original_file) == 0)
error_exit("Missing filename");
//strcat(original_file,"\""); //Add a quote at the end of the original file's name.
strcat(duplicate_file,original_file); //Combine the destination directory and the file's name to make a copy of it.
/*Copy the file */
org = fopen(original_file,"r");
dup = fopen(duplicate_file,"w");
if( org == NULL || dup == NULL)
error_exit("Error opening or creating file");
while( (ch=fgetc(org)) != EOF )
fputc(ch,dup);
That is my chunk of code that is supposed to get the file's name and then move it to C:\Program Files\File Mananger. Still, works fine without the spaces but not with them. I'm really stumped here...