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 >
Wrap
Text File
|
1993-06-08
|
555b
|
30 lines
/* inspect.c: Inspect the bytes of an object */
#include <stdio.h>
void inspect(const void *ptr, size_t nbytes)
{
int i;
const unsigned char *p = ptr;
for (i = 0; i < nbytes; ++i)
printf("byte #%d: %02X\n",i,p[i]);
putchar('\n');
}
main()
{
char c = 'a';
int i = 100;
long n = 100000L;
double pi = 3.141529;
char s[] = "hello";
inspect(&c,sizeof c);
inspect(&i,sizeof i);
inspect(&n,sizeof n);
inspect(&pi,sizeof pi);
inspect(s,sizeof s);
return 0;
}