Vote count:
0
So I created an dynamic array in C. The array contain only numbers. How can I scan the 1D array i created to print me how many numbers are greater than the last one in the array? I created the code for scanning the file only which is the following:
#include <stdio.h>
#include <limits.h>
int process( FILE *f ) {
int a, b;
if ( f == 0 ) return 0;
if ( fscanf( f, "%d", &a ) != 1 ) return INT_MIN;
if ( (b= process( f )) == INT_MIN ) return a;
if ( a > b ) return printf( "%d > %d\n", a, b ), a;
return b;
}
int main( void ) {
FILE *fp= fopen( "xxx.txt", "r" );
process( fp );
fclose( fp );
return 0;
}
Can I make the same with the array? How can I do that? Which commands should I use?
asked 44 secs ago
Scanning numbers from an array
Aucun commentaire:
Enregistrer un commentaire