Is there a C preprocessor macro to print out a struct?
问题 As far as I can tell, there's no way to print out a struct value in C . i.e., this doesn't fly: typedef struct { int a; double b; } stype stype a; a.a=3; a.b=3.4; printf("%z", a); instead you have to say: printf("a: %d\n", a.a); printf("b: %f\n", a.b); This seems like a perfect place where you could use a macro to save a vast amount of typing for arbitrary structs. Is the C preprocessor powerful enough to perform this transformation? 回答1: I think that the simplest solution (and maybe the most