User has to input date in mm/dd format, anything else creates error:
It's working in 99.99% cases. 0.01% is input like "/", which screws me up and "Bus error" appears. Any ideas?Code:cout << "Please enter the month and day (mm/dd) >> "; cin.getline(buffer, 80); if (strpbrk("/", buffer)) { month = atoi ( strtok(buffer, "/") ); if (NULL) day = atoi (strtok(NULL, "\n") ); } if (month < 1 || month > 12 || day < 1 || day > 31) cout << buffer << " is not a valid date.";




Reply With Quote