Basically I'm trying to filter out names from a text file. So the given text file would be in the format of --
Ronald, Mc Donald
And the output is only the last name. All i have so far is getting the text into arrays. I believe to solve this i have to detect the comma and basically output anything after that but I have no clue how to.
You can do this by changing the delimiter that getline uses. getline uses the '\n' as it's normal delimiter. Meaning it inputs a string until it gets to a newline character. If you use the statement getline(inputfile, string, ','); getline will retrieve a string up to the first occurance of a comma. Then you can use another getline with '\n' as the delimiter to get the rest of the line, and discard the part you don't want.