struct ID3v2_header{
char tag[3];
char ver[2];
char flag;
int size;
};
ID3v2_header readID3v2_head(string file){
char buf[10];
ifstream infile(file.c_str(),ios::binary);
ID3v2_header head;
if(!infile || !infile.read(buf, 10)){
cout<<"FAIL"<<endl;
infile.close();
return head;
}
memcpy(&head,buf,10);
infile.close();
return head;
}
サイズを出力してから実行するたびに変更されるので、どこかオーバーフローしていますか?整数は、実行ごとに異なるファイルから読み込み、なぜですか?
彼が言ったこと。また、同じ設定で同じコンパイラを使用して、同じ構造体から書かれたファイルですか? –
あなたは戻って[あなたの他の質問](http://stackoverflow.com/questions/9696308/why-is-the-size-of-this-struct-12-and-not-10)への回答を読んでください。 。 – Blastfurnace