I have 2 structures of the same type and want to compare them. The size of the structure is 420 bytes and I want to skip over the first 2 bytes when I do the comparison since I know these will never match. I am using memcmp as follows:
` typedef struct foo // total of 420 bytes
{
char c1,c2 ;
int x ;
struct temp y ;
... // lot of other members
...
...
} ;
foo f1, f2 ;
memset (&f1, 0xff, sizeof(foo) ) ;
memset (&f2,0xff, sizeof(foo) ) ;
update_foo(&f1) ; // function which updates the structure by reading value from flash memory
// Now compare 2 structures starting with value x
if ( memcmp(&f1.x, &f2.x, sizeof(foo)-2 ) == 0 )
// Do something
else
// Do something else`
The result of comparison gives me random values. I assume that when I pass "&f1.x" and "&f2.x" I am skipping the first two bytes and the comparison will be for the remaining 418 bytes. Is this assumption correct?