40 lines
674 B
C
40 lines
674 B
C
/*
|
|
Nome: Mario
|
|
Cognome: Montanari
|
|
Classe: 3AIN
|
|
Data: 16/04/2025
|
|
|
|
leggere tutti i valori con una sola fread in un array
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
|
|
#define SIZE 1000+1
|
|
|
|
void leggiNumeri(FILE * file);
|
|
|
|
int main(void) {
|
|
FILE *file = fopen("file_70.bin", "rb");
|
|
|
|
if (file != NULL) {
|
|
leggiNumeri(file);
|
|
|
|
fclose(file);
|
|
} else {
|
|
perror("Error (source)");
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
void leggiNumeri(FILE * file) {
|
|
int numeri[SIZE];
|
|
int numeriLetti = fread(numeri, sizeof(int), SIZE, file);
|
|
|
|
fclose(file);
|
|
|
|
for (int i = 0; i < numeriLetti; i++) {
|
|
printf("%d ", numeri[i]);
|
|
}
|
|
printf("\n");
|
|
} |