I have been working a small program as a way to practice C++. Here is a quick sequence of how the program works and does:
- do-loop menu (2 choices: 1) read/write 2) exit)
case 1: read/write function
case 2: return 0;
- read/write function
1)enter name of read file
2)enter name of write file
6)write << read // copy everything from data that were saved in memory from read file to write file
For some reason, the work only works: the first time it starts AND the user must enter the correct file name (file exists)
Case: If user enters the name of a file (always stalls upon read file, not write file) that exists the first time the program starts, it works. However, it works only once. Once the user returns to the mean menu and tries the same sequence, the program would say the "file" does not exists even if the user enters the exact same file name. I have tried cout the array used to store the file name. It holds the correct file name each time.
Case: If user enters a file name that does not exists, the program would not work, period.
Does anyone know what is going on? I have tried using dynamically allocated memory to make sure the file name is stored clean each time. I have tried to use different technique like trying different loops and if/else. Nothing has worked. Is there something static about the fstream?