home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- From: raph@panache.demon.co.uk (Raphael mankin)
- Path: sparky!uunet!pipex!demon!panache.demon.co.uk!raph
- Subject: Re: Moving from Pascal to C, Help please!!!!!!
- Distribution: world
- References: <4293@dozo.and.nl>
- Organization: Solvfield Ltd.
- Reply-To: raph@panache.demon.co.uk
- X-Mailer: Simple NEWS 1.90 (ka9q DIS 1.19)
- Lines: 23
- Date: Fri, 8 Jan 1993 16:32:34 +0000
- Message-ID: <726510754snz@panache.demon.co.uk>
- Sender: usenet@demon.co.uk
-
- 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.
- 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.
-
- 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.
-
- If your pointer is to a single item, then the only thing you should do with it
- is to follow it (dereference).
- --
- --------------
- Raphael Mankin Nil taurus excretum
-