I wanted to do a simple date validation to disallowed string from entering when prompt. Pls guide me. Tks.
Eg,
"Enter the publish date in DD/MM/YYYY : ghghjb
"Sorry, pls enter in DD/MM/YYYY"
"Enter the publish date in DD/MM/YYYY :
# include<iostream>
# include<string>
using namespace std;
class date
{
public : char publish_date[11];
};
date list[2];
void printbook();
int main()
{
char ch;
for(int i = 0; i < 2; i++)
{
cout << "Enter the publish date in DD/MM/YYYY : ";
cin >> list[i].publish_date;
}
cout << "Press 'L' to view the list of books...";
cin >> ch;
if(ch == 'l' || ch == 'L')
{
printbook();
}
}
void printbook()
{
for(int i = 0; i < 2; i++)
{
cout << "Book Publishing date : " << list[i].publish_date << endl << endl;
}
}