I wrote a c
program to read a MP3 file and print the TAG2 fields. The source code is:
void main(void)
{
FILE *w;
char c[10]={0};
int ver, flag, size;
w=fopen("test.mp3,"rb");
fread(c,1,3,w);
printf("TAG2 identifier:%s\n",c);
fread(&ver,1,2,w);
printf("TAG2 version:%d\n",ver);
fread(&flag,1,1,w);
printf("Flags:%d\n",flag);
fread(&size,1,4,w); //????????
..........
}
I know that the most significant bit in each byte of size is set to 0 and should be ignored.
But it seems that when read()
reads the 4 byte of size, the byte order is reversed.
How can I read the size in correct byte order?