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

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!princeton!csservices!kastle!blume
  3. From: blume@kastle.Princeton.EDU (Matthias Blume)
  4. Subject: Re: Pointer math (was Re: adding strings together)
  5. Message-ID: <1993Jan5.173245.12977@csservices.Princeton.EDU>
  6. Sender: news@csservices.Princeton.EDU (USENET News System)
  7. Reply-To: blume@kastle.Princeton.EDU (Matthias Blume)
  8. Organization: Dept. of Computer Science, Princeton University
  9. References: <1iab6dINNsq9@shelley.u.washington.edu> <C0E3Js.KIG@ocsmd.ocs.com>
  10. Date: Tue, 5 Jan 1993 17:32:45 GMT
  11. Lines: 33
  12.  
  13. In article <C0E3Js.KIG@ocsmd.ocs.com>, ted@ocsmd.ocs.com (Ted Scott) writes:
  14. |> Benjamin Ketcham (bketcham@stein.u.washington.edu) wrote:
  15. |> : It's illegal to perform addition on pointers. 
  16. |> 
  17. |> 'Tisit?  consider:
  18. |> 
  19. |> char *end;
  20. |> char buffer_stuff[128];
  21. |> 
  22. |> for(end = buffer_stuff + 128;(end > buffer_stuff && *end == ' ');end--) 
  23. |>          ;  /* null loop body */                     ^^^^^^^^^^
  24. |>                                          better to use some index func. here
  25. |> 
  26. |> Looks like addition and subtraction to me :-0
  27. |> 
  28. |> : That's one of the things I like about C.  It doesn't let you "just"
  29. |> : add two strings together, without realizing what you are doing.
  30. |> 
  31. |> I contend that C will let you do alot without realizing what you're
  32. |> doing. You can add two string pointers together, just don't expect the 
  33. |> result to be a concatenated string.
  34. |> 
  35. |> --
  36. |> 
  37. |> -Ted Scott          
  38. |> tscott@ocsmd.ocs.com           I was told that I'm a P.C. person:
  39. |> (301) 601-2252                               Politically Challenged,
  40. that is.
  41.  
  42. That's what I like: people who have deep knowledge and a full understanding
  43. of what they are posting... :-(
  44.  
  45. -Matthias
  46.