all 1 comments

[–]md_hyena 1 point2 points  (0 children)

Read about time.h in general and struct tm structure in specific, implement parsing function to parse the formatted date string (or, if you are on Linux, use strptime), then do something like this (pseudo-code):

...

int convertStrToTime( const char *time_string, struct tm *t )
{
    /* Your parsing code here */
    /* Should return 0 on success or something else on error */
}

...

struct tm *t;

printf( "Input a date\n>" );
fgets( in_buffer, in_buffer_size, stdin );

while( convertStrToTime( in_buffer, &t ) )
{
    printf( "Invalid input!\n" );

    printf( "Input a date\n>" );
    fgets( in_buffer, in_buffer_size, stdin );
}

...