dimanche 22 avril 2018

How to check if a string value is in a correct time format using c++

what code can you use to make sure that time inputted is in the correct format

cout<<"What is the time of the event?" << endl;

cin.get();

getline(cin, eventTime);

// eventime is a string

example:

user input: 12:36:27 --> valid

user input: 25:60:60 --> invalid

Aucun commentaire:

Enregistrer un commentaire