home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!cs.utexas.edu!csc.ti.com!tilde.csc.ti.com!mksol!mccall
- From: mccall@mksol.dseg.ti.com (fred j mccall 575-3539)
- Subject: Re: Moving from Pascal to C, Help please!!!!!!
- Message-ID: <1993Jan12.190826.20740@mksol.dseg.ti.com>
- Organization: Texas Instruments Inc
- References: <4293@dozo.and.nl> <726510754snz@panache.demon.co.uk>
- Date: Tue, 12 Jan 1993 19:08:26 GMT
- Lines: 42
-
- In <726510754snz@panache.demon.co.uk> raph@panache.demon.co.uk (Raphael mankin) writes:
-
- >In article <4293@dozo.and.nl> jos@and.nl writes:
-
- >>
- >>Another way to approach pointer arithmetic is first to convert the
- >>pointer(s) to character pointer(s): [ ... ] For pointer subtracion,
- >>the result of the difference between the character pointers is
- >>similarly divided by the size of the object originally pointed to.
- >>
-
- >IMHO the only thing one can say about pointer arithmetic is DON'T.
-
- There's singularly bad advice from someone with that much experience.
-
- >Regardless of what K&R or the standard say about its legality, tinkering
- >with pointers is one of the surest ways of getting into trouble. 30 years
- >of programming, in more languages than most readers of this group have even
- >heard of, has led me to this position.
-
- Then your experience hasn't been in C, in which arrays are NOT
- first-class objects. 'Tinkering' with pointers is one of the basic
- building blocks in the language.
-
- >If your pointer points to an array, use subscripting. Let the compiler's
- >optimiser work out whether there are really better ways of doing the job.
-
- And what do you do when a pointer is passed to a function? Punt?
-
- >If your pointer is to a single item, then the only thing you should do with it
- >is to follow it (dereference).
-
- You may have a lot of experience in things most people have never
- heard of (although I'd bet that a lot of us could probably say the
- same to you), but you don't appear to have sufficient experience in C
- to be making such statements.
-
- --
- "Insisting on perfect safety is for people who don't have the balls to live
- in the real world." -- Mary Shafer, NASA Ames Dryden
- ------------------------------------------------------------------------------
- Fred.McCall@dseg.ti.com - I don't speak for others and they don't speak for me.
-