I'm trying to make a program that reads emails from a text file ("fileContainingEmails.txt"), prints them on the console, and then writes them out to a different text file called "copyPasteMyEmail.txt". For some reason it's creating an output file, but no data is being written into it. I tried adding fout.close ("copyPastMyEmail.txt") at the end, but now I have a c2660 compilation error ('function' : function does not take number parameters). Help please?
You have to change line 43 to fin.open (filename.c_str()); , because open() doesn't take a string as parameter. (http://www.cplusplus.com/reference/string/string/c_str/) And line 78 has to be fout.close(); , because close() doesn't have any parameters.
Happy coding! :D
EDIT: @lowestone: "The fact that a file is being created means that you are opening the file correctly." In Dev-C++ that line gives an error.
The fact that a file is being created means that you are opening the file correctly.
I believe you want an open bracket before line 53 and a closing bracket after line 77/ Otherwise, that entire loop only happens to the last string extracted.
@Line 73 you declare another string anEmail so this is the anEmail that gets the substring. Outside the loop, anEmail is the one you declared at line 28.