I have a working program. But for some reason I cannot exit properly. I keep getting warning codes. I know i'm just missing something easy from working on this for so long.
These are the error codes i'm getting:
Unhandled exception at 0x104cee04 in languageTranslator.exe: 0xC0000005: Access violation writing location 0x108e6bf0.
There is no source code available for the current location.
As well as an End Now prompt for my solution.
I have both ways I have tried to get out. the comments out was other option I thought would work. This is the end of my do-if-else.
Thank you again!
The problem lies in line 15 of the above code. Here you are reading into EnglishArray and FrenchArray over and over. There is no guarantee that you'll stop reading before hitting the end of the array. In fact, I don't think it'll ever stop reading guaranteeing that you'll hit the end of the array.
I'm guessing that dataIn is a std::ifstream object.
Replace that while loop from lines 14 to 17 with this:
1 2
for( int i = 0; dataIn.good(); ++i) // Checks if there is an end of file or error
dataIn >> EnglishArray[i] >> FrenchArray[i]; // Reads the data
You may also want to check if the file is too big to fit into the array. If your arrays are defined like so:
for( int i = 0; dataIn.good() && i < 256; ++i) // Checks if there is an end of file or error
dataIn >> EnglishArray[i] >> FrenchArray[i]; // Reads the data