Split String to Validate

I need a help to validate a string. The string is a day with date, month and year.
For example, Sunday, November 2016.
So I need to split them to check the day, date, month and year one by one if its validate or not. Can someone help me please?

1
2
3
4
5
6
7
8
9
10
int main()
{
    int n;
    string date;
    int j = 0;
    cin>>n;
    for(int i=0; i<=n; i++){
        getline(cin,date);
    }
}
Last edited on
Someone reply and help please....
Someone reply and help please....

People will come and help when and if they feel like it. Don't rely on this forum to get your homework done.

This is a bare bones code snippet. It assumes that the user will enter input in the correct format. You will need to check for valid values and clean up after invalid input.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
struct Date
{
    string day, month;
    int year;
};

Date get_date( )
{
    cout << "enter date: ";

    Date d;
    getline( cin, d.day, ',' );
    cin >> d.month >> d.year;

    return d;
}
Topic archived. No new replies allowed.