Checking for valid input in inputfile

Hey, I'm writing a program that involves file writing. I have a question regarding that. I am reading the info from the file into 3 strings and my question is, is there any way to check for valid input. I tried using an if with something like this

1
2
3
4
5
ifstream inputfile;
inputfile.open(name.c_str());

if(!inputfile >> string1 >> string2 >> string3) throw 3;


but it shoots

 
no match for bool >> String& operator


Is there a way i can do this?
Check operator precedence!

if( !( inputfile >> string1 >> string2 >> string3 ) ) throw 3 ;

Or:
1
2
if( inputfile >> string1 >> string2 >> string3 ) { /* process input */ }
else throw 3 ;
Oh wow... I feel dumb...
Thank youu
Topic archived. No new replies allowed.