home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / c / 19256 < prev    next >
Encoding:
Text File  |  1993-01-05  |  1.3 KB  |  39 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!ocsmd!ted
  3. From: ted@ocsmd.ocs.com (Ted Scott)
  4. Subject: Pointer math (was Re: adding strings together)
  5. Message-ID: <C0E3Js.KIG@ocsmd.ocs.com>
  6. Sender: news@ocsmd.ocs.com
  7. Organization: Online Computer Systems, Inc.
  8. X-Newsreader: Tin 1.1 PL5
  9. References: <1iab6dINNsq9@shelley.u.washington.edu>
  10. Date: Tue, 5 Jan 1993 16:38:14 GMT
  11. Lines: 26
  12.  
  13. Benjamin Ketcham (bketcham@stein.u.washington.edu) wrote:
  14. : It's illegal to perform addition on pointers. 
  15.  
  16. 'Tisit?  consider:
  17.  
  18. char *end;
  19. char buffer_stuff[128];
  20.  
  21. for(end = buffer_stuff + 128;(end > buffer_stuff && *end == ' ');end--) 
  22.          ;  /* null loop body */                     ^^^^^^^^^^
  23.                                          better to use some index func. here
  24.  
  25. Looks like addition and subtraction to me :-0
  26.  
  27. : That's one of the things I like about C.  It doesn't let you "just"
  28. : add two strings together, without realizing what you are doing.
  29.  
  30. I contend that C will let you do alot without realizing what you're
  31. doing. You can add two string pointers together, just don't expect the 
  32. result to be a concatenated string.
  33.  
  34. --
  35.  
  36. -Ted Scott          
  37. tscott@ocsmd.ocs.com           I was told that I'm a P.C. person:
  38. (301) 601-2252                               Politically Challenged, that is.
  39.