Hello! I've been struggling for a while, so hopefully you can help!
I need to:
#1 - validate that the file can be opened (think I've accomplished)
#2 - validate the data in the file. (f for female, m for male, the number is a GPA. (So validate the character is either f or m and reads that, validate GPA is a number)
#3 - Call the void function into main.
Sample Data for problem:
f2.5
f4.0
m1.4
m3.4
m2.9
f0.9
m1.2
m3.3
This is my code thus far for the void function:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
void openFiles(string filenameIn, string filenameOut){
ifstream inFile;
ofstream outFile;
cout << "Please enter the name of the file: " <<endl; //asks user for the file name
getline (cin, filenameIn);
filenameIn += ".txt"; //user doesn't need to put .txt at the end of the file name.
inFile.open(filenameIn.c_str()); //opens input file name
if (inFile.fail()) { //can't find file, it will fail
cout << "Sorry, I was unable to open file." << endl;
exit(1);
}
}