C++ help please 0 replies

Please wait...

The_Computer_Wizard

The Force is strong with him

50 XP

10th September 2006

0 Uploads

321 Posts

0 Threads

#1 11 years ago

ok, i have to finish this lab for c++ by midnight tonight and IM STUCK basically i have to "secure" the code, or at least as secure as we can with what we have learned meaning i need to make it if a number is entered instead of a letter the program gives an error and closes, or visa versa anyway we have to read in from a file and this is the code i have so far (note im just writing a part of the code, assume the structs and things exist) ifstream fin; student cs141[64]; int i=0; fin.open("gradebook.txt"); if (fin.fail()) { cerr<<"Can't find the file"<>cs141[i].studentID) { cerr<<"Cant read student ID"; } now this is my question, that segment works, meaning if something other than a number is entered into the first spot in gradebook.txt it gives the error, but this next section gives an error if (!fin>>cs141[i].name) { cerr<<"Check your file"<