Interpréter une chaîne de caractères comme une valeur numérique à virgule flottante de type float

Author:


Download

/*
 
  float  strtof ( const char * restrict s , char ** restrict endptr  );    (C99)
 
*/
 
  #include 
  #include 
  #include 
 
  int main(void)
  {
	char in[1024], *start = in, *next = in;
	float val;
	puts( "Taper un nombre à virgule:" );
	scanf( "%[^n]", in );
 
	puts( "Vous avez entré:" );
	while ( 1 )
	{
	 val = strtof( start, &next );
	if ( next == start )
        break ;
	printf( "t%gn", val );
	start = next;
}
puts( "Done." );
 
    return 0;
  }