From: broeker AT acp3bf DOT knirsch DOT de (Hans-Bernhard Broeker) Newsgroups: comp.os.msdos.djgpp Subject: Re: Help to read array from text file Date: 16 Aug 1999 15:44:09 +0200 Organization: RWTH Aachen, III. physikalisches Institut B Lines: 16 Message-ID: <7p94j9$jhi@acp3bf.knirsch.de> References: <7p2s92$6b95e$2 AT titan DOT xtra DOT co DOT nz> NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de X-Trace: nets3.rz.RWTH-Aachen.DE 934811052 7505 137.226.32.75 (16 Aug 1999 13:44:12 GMT) X-Complaints-To: abuse AT rwth-aachen DOT de NNTP-Posting-Date: 16 Aug 1999 13:44:12 GMT X-Newsreader: TIN [version 1.2 PL2] To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Steve (malex AT xtra DOT co DOT nz) wrote: > 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. As is, your program doesn't even begin to read *numbers* from the input file. Not even 'lines' are read: it just reads characters and incorrectly treats them like strings. You'll want to look up functions like fscanf() or sscanf() (the "%d" format spec, in particular) for parsing of numbers, and 'fgets()' for reading whole lines of text in one go, so you can parse them with sscanf(), later on. -- Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.