Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- main()
- {
- int isIncorrect = 1;
- do {
- char fullTime[6];
- scanf("%s",fullTime);
- // check time format
- if( fullTime[5]!='\0') {
- printf("Too many characters!");
- }
- else if (fullTime[2] != ':') {
- printf("Wrong format!");
- }
- else if( !(isdigit(fullTime[0]) && isdigit(fullTime[1]) && isdigit(fullTime[3]) && isdigit(fullTime[4]) ) ) {
- printf("Not a number!");
- }
- else {
- printf("%s",fullTime);
- isIncorrect=0;
- }
- puts("");
- }
- while( isIncorrect );
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement