Message-ID: <375FBFC0.8074E939@melbpc.org.au> Date: Thu, 10 Jun 1999 23:38:08 +1000 From: Peter Russell Organization: Melbourne PC User Group X-Mailer: Mozilla 4.6 [en] (Win95; I) X-Accept-Language: en,ru MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: fread Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com Hi all I'd like some info on what I am doing wrong here. This block of code works perfectly in Borland C 3.1 and in MS QC ver 6 but gives an erroneous result in DJGPP. It reads a binary file into an array of structures and displays to screen. Here is the code. Thanks Pete int read_file(void); typedef struct { char title[30]; char author[30]; int year; } BOOK; main() { clrscr(); if(read_file()); // else // { // get_data(); // write_file(); // } } int read_file(void) { int i = 0; FILE *infile; BOOK book[5]; if ((infile = fopen("A:\\book.bin", "rb")) == NULL) { printf("\n\nCould not open file"); printf("\n\nPlease check disk with file 'book.bin' is in the A: drive"); printf("\n\nExiting the program"); return 0; } else { for (i = 0; i < 5; i++) { fread(&book[i], sizeof(book[i]), 1, infile); printf("%s %s %d\n", book[i].title, book[i].author, book[i].year); } } }