use printf(“%s”,..) to print a struct, the struct's first variable type is 'char *', why can get a right string stored in 'char *'?
问题 In C language,define a struct like this: typedef struct str { char *s; int len; }str; int main() { str a; a.s = "abc" printf("%s", a); return 0; } the output is: "abc", I want to konw why can get this? I guess the complier think printf("%s", a) as printf("%s", *&a) because &a is equal to &a.s, so *&a is equal to *&a.s, right? but if so, if I put the int len at the first in the struct body like this: typedef struct str { int len; char *s; }str; int main() { str a; a.len = 10; printf("%d",