标签:oid int argc ret strcpy blog 16进制 printf show
打印内存信息
1 #include <stdio.h> 2 3 // 打印内存信息 4 void showMemoryHex(void* ptr, int size) { 5 unsigned char* bytes = (unsigned char*)ptr; 6 for (int i = 0; i < size; i++) { 7 printf(" %02x", bytes[i]); 8 } 9 }
测试
struct MyStruct { int age; char name[12]; }; int main(int argc, char* argv[]) { MyStruct tony; { memset(&tony, 0, sizeof(MyStruct)); tony.age = 123; strcpy(tony.name, "tony"); } MyStruct* pTony = &tony; showMemoryHex((void*)pTony, sizeof(MyStruct)); getchar(); return 0; }
标签:oid int argc ret strcpy blog 16进制 printf show
原文地址:http://www.cnblogs.com/baigoogledu/p/7098253.html