Currently I am able (I think) to open a file using fopen. For testing purposes I want to be able to pass the file's contents to an output file, but I'm not getting the desired results. Here is some code:
#include <stdio.h>
#include <string.h>
int main(int argc, char* argv[]){ //practice on utilizing IO
char filepath[100];
char filepath2[100];
strcpy(filepath,"./");
strcpy(filepath,"./");
char typed[90];
char msg[1024];
FILE * new_file;
FILE * old_file;
// printf("Input file to be created\n");
printf("File to be opened as input: \n");
printf("--->");
fgets(typed,90,stdin); //read in file name
strtok(typed, "\n");
strcat(filepath,typed);
old_file = fopen(filepath, "r");
printf("file to output to: \n");
fgets(filepath2,100, stdin);
strtok(filepath2, "\n");
///attempt to create that file
new_file = fopen(filepath2,"w");
//printf("%s\n", msg);
}
Any help is appreciated.
freopenis inappropriate here). However, the program does not include the commands that would read data from the old file and write that data to the new file.freopen?