Well, it's not C++, but here is some old C code that'll probably compile or not depending on your compiler and the available libraries and settings. You'll have to fiddle with it a bit, but it is here.
These define statements are used in calls to functions later.
#define IN_F_NAME "Test.txt" /* Filename being copied from. */
#define OUT_F_NAME "Copy.txt" /* Filename being copied to. */
#define READ "rt" /* Sets up parameters for a read only text file. */
#define WRITE "wt" /* Sets up parameters for a write only text file. */
Prompt the user to press a key to continue the program.
printf("\t\t\tPress Any Key to Continue...\n");
Wait for a key press and discard it.
FILE * file_open(char * name, const char * params)
FILE * cur;
if((cur=fopen(name,params)) == NULL)
puts("Error Opening File");
void make_copy(FILE * cur_in, FILE * cur_out)
while(0 == feof(cur_in))
fscanf(cur_in, "%c1", &temp);
fprintf(cur_out, "%c", temp);
void close_files(FILE * cur_in, FILE * cur_out)
FILE * in, * out;
Works fine with Dev-C++ as a console project for C. Hope this helps.