-thats exactly how my code looks like in codeblocks, just didnt copy everything SORRY!.. anyway i get the following errror msg from the terminal!
1 2 3 4 5
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
This application has requested the Runtime to terminate it in an unusual w
Please contact the application's support team for more information.
Can you download this and run the program in it. I've compiled the code and included the input file too. It runs fine in my computer. Tell me whether it works or not.
(Its a zip file. You need to extract it). http://wikisend.com/download/361082/fileio.zip
It's not a good idea to use eof() in a while loop. For example, in your code, if the file has not been opened successfully, the fail() flag will be set, but eof() will never be set. The loop could continue until the vector is unable to allocate any more elements, then crash.