vendredi 6 octobre 2017

Validating a date format in c++

I'm trying to validate a date format on on a line such as this one (01 10 2017) by creating a stream.

        if(i%5==4){ //DATE
            std::string date;
            int day;
            int month;
            int year;
            std::ostringstream oss(date);
            oss >> day;
            oss >> month;
            oss >> year;
            if (day >=0 && day <= 31){
                return true;}
            if (month >=01 && month <= 12){
                return true;}
            if (annee >=1900){
                return true;}
        }

However, the code doesn't compile. What could I do to improve the validation?

Thank you

Aucun commentaire:

Enregistrer un commentaire