Just an update...
Got the program fully functional thanks to you guys! I can give it a complete garbage file and it will just put up error messages and no crashes.
If I give it a file with parts from the line missing, and it will throw errors for the part of the line that isn't there but will keep parsing the parts that are there. I absolutely adore my new creation and now only need to make a windows interface for it.
EDIT: This is the updated snippet that I posted earlier.
Code:
int parseTXT::checkDate(string checkD) {
if (checkD.find("ERROR",0) == string::npos) {
int chkYear, chkMonth, firstD, secondD, chkDay, days1, month1;
if (checkD.find("-",0) != string::npos) {
firstD = checkD.find("-",0);
} else { return 0; }
if (checkD.find("-", (firstD +1)) != string::npos) {
secondD = checkD.find("-", (firstD + 1));
} else { return 0; }
month1 = firstD + 1;
days1 = secondD + 1;
stringstream(checkD.substr(0, 4)) >> chkYear;
stringstream(checkD.substr(days1, 2)) >> chkDay;
stringstream(checkD.substr(month1, 2)) >> chkMonth;
if ((chkYear < 1990) || (chkYear > 2100)) {
return 0;
}
if ((chkDay <= 0) || (chkDay > 31)) {
return 0;
}
if ((chkMonth <= 0) || (chkMonth > 12)) {
return 0;
}
return 1;
}
return 0;
}