How do you compare structs for equality in C?
问题 How do you compare two instances of structs for equality in standard C? 回答1: C provides no language facilities to do this - you have to do it yourself and compare each structure member by member. 回答2: You may be tempted to use memcmp(&a, &b, sizeof(struct foo)) , but it may not work in all situations. The compiler may add alignment buffer space to a structure, and the values found at memory locations lying in the buffer space are not guaranteed to be any particular value. But, if you use