home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ogicse!uwm.edu!caen!saimiri.primate.wisc.edu!nntp.msstate.edu!Ra.MsState.Edu!cee1
- From: cee1@Ra.MsState.Edu (Charles Evans)
- Newsgroups: comp.lang.c
- Subject: Need help reading floats from file
- Message-ID: <cee1.721108743@Ra.MsState.Edu>
- Date: 7 Nov 92 03:59:03 GMT
- Article-I.D.: Ra.cee1.721108743
- Sender: news@ra.msstate.edu
- Organization: Mississippi State University
- Lines: 33
- Nntp-Posting-Host: ra.msstate.edu
-
- Ok, in getting data for an experiment to look at, I have
- 200 .xx floating point number, just a decimal point and 2 decimal
- places, put in 20 x 20 in a data file.
-
- How can I read them into an array.. all i could think of was do
- a HUGE fgets/sscanf thing with "%f %f ... %f".. 20 times and put into
- 20 parts of an array like : value[i++][j] on an on until i=20 then
- reset i and increment j..
-
- but i get weird errors from dos and qemm.. something is wrong.
- why cant i (i can in basic :)) just keep reading in a floating point number
- or read it in as a small string until the first whitespace?
-
- or something. thanks
-
-
- data file looks like:
-
- .11 .33 .00 .......
- .23 .45 .23 .......
- . . .
- . . .
-
- 20 x 20
-
- thanks
- chuck
-
- --
- +--------------------+-----------------------+------------------------+
- | Charles E. Evans | cee1@ra.msstate.edu | Fear God |
- | iDLE CHATTEr | cee1@MSSTATE.BITNET | Love the brotherhood |
- | Idle chatteR |cevans@abe.msstate.edu | Pray without ceasing |
-