I was doing fine in my C++ class until we hit functions. Maybe we are covering material too fast for me. I have three different books that I am using with a fourth ordered. My issue with this program is that I have to read in a text file with last name, first name and/or middle name. The output is to be first name, last name. I go from 3 errors to up to 29 at one point. The compiler mostly complains about my getline and my cin. If someone could point me to a specific line I should focus on and/or a good reference book with examples, I would greatly appreciate it.
You need to pass the getline function the input stream you wish to read from, and the name of the string to read the data into, and an optional delimiter.
getline(inFile, lastName, ','); for example.
cin fetches from the standard input stream, which is usually the keyboard. You can change it to be somehting else, but I wouldn't recommend that for the moment.
Thank you so much. I wished I found this site earlier in my C++ class. Very informative. I am only now having an issue with an error C2065, outFile undeclared identifier. I don't understand as the outFile and inFile were declared in main. Also should I not open the outfile until I am in the function writing to it?