home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_11_08 / 1108115a < prev    next >
Text File  |  1993-06-08  |  555b  |  30 lines

  1. /* inspect.c:   Inspect the bytes of an object */
  2. #include <stdio.h>
  3.  
  4. void inspect(const void *ptr, size_t nbytes)
  5. {
  6.     int i;
  7.     const unsigned char *p = ptr;
  8.  
  9.     for (i = 0; i < nbytes; ++i)
  10.         printf("byte #%d: %02X\n",i,p[i]);
  11.     putchar('\n');
  12. }
  13.  
  14. main()
  15. {
  16.     char c = 'a';
  17.     int i = 100;
  18.     long n = 100000L;
  19.     double pi = 3.141529;
  20.     char s[] = "hello";
  21.  
  22.     inspect(&c,sizeof c);
  23.     inspect(&i,sizeof i);
  24.     inspect(&n,sizeof n);
  25.     inspect(&pi,sizeof pi);
  26.     inspect(s,sizeof s);
  27.     return 0;
  28. }
  29.  
  30.