I'm trying to read in a file that is in the format:
name:project:specification.
An example file:
John Doe:Cat:ABCDE.
Carly:Mouse:DEFG. |
I also want to check if there are any errors in the formatting.
So far I have opened the file and am reading line by line:
1 2 3 4 5 6 7 8
|
std::ifstream inFile;
inFile.open("file.txt")
std::string line;
while(std::getline(inFile, line))
{
}
| |
I know how to set a delimiter, however I'm not sure of a clean way to extract each section while also checking for the period at the end.
I was thinking along the lines of using two getlines, the first with '.' as the delimiter, putting the result into a std::stringstream and using getline again with ":" as the delimiter, however I'm not sure how great this would be for error checking.
I'm not after something to copy-paste, just suggestions on something in-line with good practice.
Any suggestions are welcome, thanks!