For example if the input file contains "my name is ." the content copied in the output file will be "my name is .." Also wanted to ask if the input and output files does not exist will "fopen" create them in the specified location.
MY CODE:
#include<stdio.h>
void copy(FILE *,FILE *);
int main()
{
FILE *input = fopen("/Users/vasuparbhakar/Documents/C Programs/File Handling/copy file/input.txt","r");
FILE *output= fopen("/Users/vasuparbhakar/Documents/C Programs/File Handling/copy file/output.txt","w");
if(input == NULL)
{
fprintf(stderr,"Error opening file: input.txt");
return 0;
}
if(output == NULL)
{
fprintf(stderr,"Error opening file: output.txt");
return 0;
}
copy(input,output);
fclose(input);
fclose(output);
return 0;
}
void copy(FILE *from,FILE *to)
{
char x;
while(!feof(from))
{
fscanf(from,"%c",&x);
fprintf(to,"%c",x);
}
}