How do I dump an arbitrary struct in C?
问题 I don't know which direction to go,perhaps something like reflection will help? 回答1: The answer of @Kerrek SB works realy well, I just post how to use it in a function using a void pointer. int dump(void *myStruct, long size) { unsigned int i; const unsigned char * const px = (unsigned char*)myStruct; for (i = 0; i < size; ++i) { if( i % (sizeof(int) * 8) == 0){ printf("\n%08X ", i); } else if( i % 4 == 0){ printf(" "); } printf("%02X", px[i]); } printf("\n\n"); return 0; } int main(int argc,