直接上代码
#include "stdafx.h"
#include <iostream>
#include "stdio.h"
using
namespace
std;
typedef
struct
foo
{
int
first;
char
second;
char
third;
char
fourth;
void
*fifth;
} foo;
void
print_struct_content(
void
*strp,
size_t
size)
{
size_t
i;
char
*print=(
char
*)strp;
int
formatter=0;
for
(i=0; i<size; i++)
{
printf
(
"%02X "
,print[i]);
formatter++;
if
((formatter%4)==0)
{
printf
(
"\n"
);
}
}
}
int
_tmain(
int
argc, _TCHAR* argv[])
{
foo *p=
new
foo;
print_struct_content((
void
*)p,
sizeof
(foo));
delete
p;
return
0;
}