/* File: fread1.c Practicing with fread() */ #include main() { int n, r, count = 0 ; FILE *ifile ; ifile = fopen("binary", "rb") ; while(1) { r = fread(&n, sizeof(int), 1, ifile) ; if (r <= 0) break ; printf("%d\n", n) ; count++ ; } printf("%d items were found in the input file\n", count) ; close(ifile) ; }