home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / qc_prog / chap08 / peek.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-04-05  |  532 b   |  22 lines

  1. /* peek.c    -- demonstrates how to cast an int to a  */
  2. /*              pointer                               */
  3.  
  4. main()
  5. {
  6.     char *mem_ptr;
  7.     unsigned int address;
  8.  
  9.     while (1)
  10.         {
  11.         printf("Examine what memory location?\n");
  12.         printf("Enter location in decimal: ");
  13.         if (scanf("%u", &address) != 1)
  14.             break;
  15.  
  16.         mem_ptr = (char *)address;   /* cast  */
  17.  
  18.         printf("The value in %u is 0x%02X\n",
  19.                 address, (unsigned char)*mem_ptr);
  20.         }
  21. }
  22.