1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| FILE* pf = fopen( "MonFichier" , "rt" );
if ( pf ) {
char buf[200];
while ( fgets( buf , sizeof buf , pf ) ) {
char str[200];
for ( const char* ptr = buf ; ; ptr += strlen( str ) ) {
sscanf( ptr , "%s" , str ); // lit le mot suivant (ignore les séparateurs)
if ( *str == '\0' ) // fin du buffer
break;
if ( *str >= '0' && *str <= '9'
|| *str=='-' && str[1]>='0' && str[1]<='9' ) { // semble être un nombre
double nbrLu = atod( str );
printf( "nombre lu : %lf\t" , nbrLu );
}
}
}
fclose( pf );
} |
Partager