home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!ocsmd!ted
- From: ted@ocsmd.ocs.com (Ted Scott)
- Subject: Pointer math (was Re: adding strings together)
- Message-ID: <C0E3Js.KIG@ocsmd.ocs.com>
- Sender: news@ocsmd.ocs.com
- Organization: Online Computer Systems, Inc.
- X-Newsreader: Tin 1.1 PL5
- References: <1iab6dINNsq9@shelley.u.washington.edu>
- Date: Tue, 5 Jan 1993 16:38:14 GMT
- Lines: 26
-
- Benjamin Ketcham (bketcham@stein.u.washington.edu) wrote:
- : It's illegal to perform addition on pointers.
-
- 'Tisit? consider:
-
- char *end;
- char buffer_stuff[128];
-
- for(end = buffer_stuff + 128;(end > buffer_stuff && *end == ' ');end--)
- ; /* null loop body */ ^^^^^^^^^^
- better to use some index func. here
-
- Looks like addition and subtraction to me :-0
-
- : That's one of the things I like about C. It doesn't let you "just"
- : add two strings together, without realizing what you are doing.
-
- I contend that C will let you do alot without realizing what you're
- doing. You can add two string pointers together, just don't expect the
- result to be a concatenated string.
-
- --
-
- -Ted Scott
- tscott@ocsmd.ocs.com I was told that I'm a P.C. person:
- (301) 601-2252 Politically Challenged, that is.
-