I am relatively new to C++ and I am trying to read in a number of text files (i.e. files which contain dictionary entries) and modify some things in each of the files. After some changes have been made I then want to output the text to a new file. For the moment I am trying to read in one of the files and write it to a new file but only garbage is written to the file!
Can you have a look at some code........
#define MAXLENGTH 30
cin>>filenameIn; //get the filename
ifstream infile(filenameIn); //open the file
cout<<"Enter the filename to write to:";
ofstream outfile(filenameOut); //open the file to write to
if(infile) //read until end of file
cout<<ch; //output the letters to the screen
outfile<<ch; //output to the new file
} //end while
infile.close(); //close the file for reading
outfile.close(); //close the file for writing