Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validate formatted input from a file?

Status
Not open for further replies.

randi

Programmer
Jun 20, 2000
3
US
Can anyone recommend the best way to validate text input from an ascii file?
Each line of my input file is expected to be:

Some Text \t Some Text \t Some Text\n

However, if the program encounters a line with only whitespace, an exception is raised.

Here is a code snippet (without any validation):

while (fgets(line, 209, inF) != 0) {
text1 = strtok (line, "\t");
text2 = strtok (NULL, "\t");
text3 = strtok (NULL, "\t");
}

It seems like a job for Regexes - but I don't know how to do that in C++.

Thanks in advance for any help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top