#include #include void main() { FILE *fp; int c; long value; fp = fopen( "file", "r" ); value = 0; c = fgetc( fp ); while( isdigit(c) ) { value = value*10 + c - '0'; c = fgetc( fp ); } ungetc( c, fp ); /* put last character back */ printf( "Value=%ld\n", value ); fclose( fp ); }