home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / c / 18601 < prev    next >
Encoding:
Text File  |  1992-12-21  |  1.3 KB  |  37 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!math.fu-berlin.de!informatik.tu-muenchen.de!hphalle6!behrenss
  3. From: behrenss@Informatik.TU-Muenchen.DE (Soenke Behrens)
  4. Subject: Re: Peek/Poke in C
  5. References: <BV5XVB5w165w@blackwlf.gwinnett.com>
  6. Sender: news@Informatik.TU-Muenchen.DE (USENET Newssystem)
  7. Organization: Technische Universitaet Muenchen, Germany
  8. Date: Fri, 18 Dec 1992 11:59:35 GMT
  9. Message-ID: <behrenss.724679975@hphalle6>
  10. Lines: 25
  11.  
  12. >ericwebb@blackwlf.gwinnett.com (eric webb) writes:
  13. >>Hi again.. does anyone know how to do equivalent of BASIC's PEEK & POKE
  14. >>statements in C?
  15.  
  16. Very implentation-specific. Some architectures allow something along
  17. the lines of
  18.  
  19. char *address;
  20.  
  21. address = 0x678090;
  22. *address = 80; /* poke $678090,80 */
  23. printf ("And peek gives us: %d\n",*address);
  24.  
  25. This will, of course, only work on those architectures where a pointer
  26. actually contains a physical address, which is a rare case anyway.
  27.  
  28. My advice: Stay away from PEEK and POKE. If you absolutely have to do
  29. it, at least put it in its own source file and comment it heavily.
  30.  
  31. Soenke
  32. -- 
  33. ===========================================================================
  34. More than silver, more than gold, I need   !    behrenss@informatik.
  35. electricity. I need it for my dreams.      !    tu-muenchen.de
  36. (RACTER)                                   !  FIDO: 2:246/13 Soenke Behrens
  37.