21 lines
366 B
C
21 lines
366 B
C
|
#include <stdio.h>
|
||
|
#include <ctype.h>
|
||
|
|
||
|
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 );
|
||
|
}
|