[Solved] How to read double value with semicolon between instead of a dot


1 minute and 23 seconds is not the same as 1.23 minutes.

One way to do this:

int min, sec;
double dur = -1.0; // initialize to an invalid duration

if ( scanf( "%d:%d", &min, &sec ) == 2 )
{
  dur = min + sec/60.0;
}
else
{
  fprintf( stderr, "Invalid duration, try again\n" );
  while ( getchar() != '\n' ) // clear out the input stream
    ; // empty loop
}

5

solved How to read double value with semicolon between instead of a dot