同じタイプの構造が 2 つあり、それらを比較したいと考えています。構造体のサイズは 420 バイトで、最初の 2 バイトは決して一致しないことがわかっているため、比較を行うときにスキップします。次のように memcmp を使用しています。
` 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`
比較の結果、ランダムな値が得られます。「&f1.x」と「&f2.x」を渡すと、最初の 2 バイトがスキップされ、残りの 418 バイトが比較されると仮定します。この仮定は正しいですか?