下面给出一个带坑的code:
看到的小伙伴可以猜下。打印equal还是not equal。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct test {
int i;
char c;
};
int main() {
struct test t1 = {0};
struct test t2 = {0, 0};
#if 1
int len;
char *p = (char *)&t2.c + 1;
printf("len = %d\n", len);
#endif
if (memcmp(&t1, &t2, sizeof(struct test)) == 0) {
printf("equal\n");
} else {
printf("not equal\n");
}
return 0;
}