Why doesn't memcpy work when copying a char array into a struct?
问题 #define buffer 128 int main(){ char buf[buffer]=""; ifstream infile("/home/kevin/Music/test.mp3",ios::binary); infile.seekg(-buffer,ios::end); if(!infile || !infile.read(buf,buffer)){ cout<<"fail!"<<endl; } ID3v1 id3; cout<<sizeof(id3)<<endl; memcpy(&id3,buf,128); cout<<id3.header<<endl; } struct ID3v1{ char header[3]; char title[30]; char artist[30]; char album[30]; char year[4]; char comment[28]; bool zerobyte; bool track; bool genre; }; When I do the memcpy, it seems to be pushing too much