home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / c / 12870 < prev    next >
Encoding:
Text File  |  1992-08-27  |  1.3 KB  |  32 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!email!hp
  3. From: hp@vmars.tuwien.ac.at (Peter Holzer)
  4. Subject: Re: Why should POINTERS be so damn hard to understand ?
  5. Message-ID: <1992Aug27.181844.11739@email.tuwien.ac.at>
  6. Sender: news@email.tuwien.ac.at
  7. Nntp-Posting-Host: quasi.vmars.tuwien.ac.at
  8. Organization: Technical University Vienna, Dept. for Realtime Systems, AUSTRIA
  9. References: <l9nl34INNhln@almaak.usc.edu> <25233@castle.ed.ac.uk> <1992Aug27.135946.6622@infonode.ingr.com> <17islrINNh6c@early-bird.think.com>
  10. Date: Thu, 27 Aug 1992 18:18:44 GMT
  11. Lines: 19
  12.  
  13. barmar@think.com (Barry Margolin) writes:
  14.  
  15. >for (_i=(char *)a; _i<a+1000*sizeof(int); _i+=sizeof(int))
  16. >    *(int *)_i = whatever();
  17.  
  18. >I would epect this to produce almost identical code.  And in a language
  19. >where pointers weren't typed, you wouldn't need all the casting.
  20.  
  21. You would still have to cast _i to (int *), or the compiler couldn't
  22. know how much memory it should access (1 byte? 1 word? ...)
  23.  
  24. Anyway, why should I type sizeof(int), when the compiler can do it for
  25. me?
  26.  
  27. -- 
  28. |    _  | Peter J. Holzer                       | Think of it   |
  29. | |_|_) | Technical University Vienna           | as evolution  |
  30. | | |   | Dept. for Real-Time Systems           | in action!    |
  31. | __/   | hp@vmars.tuwien.ac.at                 |     Tony Rand |
  32.