我正在制作一个程序,我向用户询问日期并将其与当前日期进行比较。所有功能都在那里,但我似乎无法验证日期、月份和年份是数字,因此输入字母会使程序崩溃。有任何想法吗?(注意:do while 循环中的函数按预期工作)
do // This do while loop forces the user to enter a valid date before moving on
{
cout << "Enter the lent date in the format dd/mm/yyyy: " << endl;
cin >> day1 >> buffer >> month1 >> buffer >> year1;
if(cin.fail())
{
continue;
}
}
while (!validateDateSize(day1, month1, year1) || !validateDateIntegrity(day1, month1, year1));