home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ferkel.ucsb.edu!taco!gatech!swrinde!cs.utexas.edu!sun-barr!ames!ncar!noao!amethyst!organpipe.uug.arizona.edu!news
- From: dave@cs.arizona.edu (Dave Schaumann)
- Newsgroups: comp.lang.c
- Subject: Re: Novice Questions
- Message-ID: <1992Aug30.162657.24698@organpipe.uug.arizona.edu>
- Date: 30 Aug 92 16:26:57 GMT
- References: <1992Aug30.004740.8973@eskimo.celestial.com>
- Sender: news@organpipe.uug.arizona.edu
- Reply-To: dave@cs.arizona.edu (Dave Schaumann)
- Organization: University of Arizona
- Lines: 27
- In-Reply-To: maven@eskimo.celestial.com (Norman Hamer)
-
- In article <1992Aug30.004740.8973@eskimo.celestial.com>, maven@eskimo (Norman Hamer) writes:
- > 1. Given a char array, say char foo[256];, is *foo the same as foo[0]
-
- Yes: foo[0] becomes *(foo+0) becomes *foo.
-
- >and is foo+x the same as foo[x] in all implementations?
-
- No. As I indicated above, foo[x] is the same as *(foo+x).
- (so &foo[x] is the same as foo+x)
-
- > 2. What's the best way to read in a text configuration file? I've seen
- >code like this:
-
- [other options deleted]
- > while(fgets(line, 80, fd) != NULL)
- > {
- > /*Muck with the data */
- > }
-
- This is the way I've seen it done most often (at least in C), and I prefer
- it. It's the simplest of the lot, and therefore the easiest to get right,
- and the easiest to understand later. As you pointed out with the others,
- you have to be very careful to be sure you got the control flow and calls
- to feof() just right, or you're screwed.
-
- --
- --- jumbo shrimp --- pretty ugly --- awfully nice --- constant change ---
-