If you want to compare if two structs contain exactly the same thing, you can use memcmp() - however, it relies on the fact that you ALWAYS fill the struct with zero before you set any of the other data. This is due to what Elysia hints at: Structs usually have alignment padding which makes "holes" - these holes are "undefined" unless you fill the structure with something well defined (and zero is the best value here, as it also means that any numeric values are zero).
Beware however that if you have pointers, the value of the pointer itself has to be equal. For example the "name" pointer in your struct, if you do:
Code:
mystructure a, b;
...
char *str = "Abcde";
a->name = malloc(strlen(str)+1);
strcpy(a->name, str);
...
b->name = malloc(strlen(str)+1);
strcpy(b->name, str);
...
if (memcmp(a, b, sizeof(a)) == 0) {
printf("They are equal\n");
}
...
This code will NOT say "They are equal", since the two pointers to "Abcde" have different values.
--
Mats