I am suppose to read in from a text document information written as a name , a space, and a decimal value. For example, a line from a file might have:
Tiger 56.3
What I need to do is validate that first part is a string containing only letters and second part containing only digits including decimals. I have the following basic code so far:
ifstream input("data.txt");
while(!input.eof())
{
string name;
double score;
input >> name;
input >> score;
}
How do I go about doing this ?
istreamformatters are not really suitable for robust input validation.