From: "Steve" Newsgroups: comp.os.msdos.djgpp Subject: Help to read array from text file Date: Sat, 14 Aug 1999 16:44:09 +1200 Organization: Customer of Telecom Internet Services Lines: 46 Message-ID: <7p2s92$6b95e$2@titan.xtra.co.nz> NNTP-Posting-Host: 202-27-179-97.dialup.xtra.co.nz X-Trace: titan.xtra.co.nz 934605922 6661294 202.27.179.97 (14 Aug 1999 04:45:22 GMT) X-Complaints-To: abuse AT xtra DOT co DOT nz NNTP-Posting-Date: 14 Aug 1999 04:45:22 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2014.211 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Well, I am trying to read a text file which contains 5 rows and 5 columns of numbers into an array, then print out the array on screem in the same format that is was in the text file so that individual parts of the array can be summed, counted etc. so far, I have not been able to do so, any help with this would be very welcome. Included is what I have come up with so far, yer ok, so I am also new to this, there could be obvious mistakes in there of which I cannot see. Below is the file that I have been working on. Steve #include #include main() { FILE * aa; char fname[81], t[5][5]; int a, ch, team, last; printf("Enter name of file to read: "); scanf("%80s", fname); aa = fopen(fname, "r"); if (aa == NULL) { fprintf(stderr, "File cannot be opened.\n"); exit(1); } while ((ch = getc(aa)) >= 0) { /* while not EOF */ for (a = 0; a <= 26; ++a) fscanf(stderr, "%s", t[a]); fprintf(stderr, "%s \n", t[a]); } fclose(aa); return 0; }