The "r" function works well!
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
FILE *file_r, *file_w;
int c;
char fileread[40];
char filewrite[40];
printf("Enter filename to be copied: ");
gets(fileread, 40, stdin);
fileread[strlen(fileread)-1] = '\0';
file_r = fopen(fileread, "r");
while(file_r == NULL)
{
printf("Invalid file, ealnter again!");
fgets(fileread, 40, stdin);
fileread[strlen(fileread)-1] = '\0';
printf("%s\n", fileread);
file_r = fopen(fileread, "r");
}
printf("Enter name of file copy");
fgets(filewrite, 40, stdin);
fileread[strlen(fileread)-1] = '\0';
file_w = fopen(filewrite, "w");
while(file_w == NULL)
{
printf("Invalid Filename enter again");
fgets(filewrite, 40, stdin);
fileread[strlen(fileread)-1] = '\0';
file_r = fopen(fileread, "w");
}
c = getc(file_r);
while(c != EOF)
{
putc( c, file_w);
c = getc(file_r);
}
fclose(file_r);
fclose(file_w);
printf("Files succesfully copied");
return 0;
}