0
我试图在C中读取.au
文件的头文件,并且我将所有值存储在struct
中,但无法将它们转换为Little Endian格式。AU文件的读取头 - C
我偶然发现了一个方法,ntohl
应该把字节和转换为主机格式,但编译我的程序时不断收到错误。
undefined reference to 'ntohl'
#include <stdio.h>
struct header
{
char magic[5];
int offset;
int size;
int encoding;
int rate;
int channels;
};
int main()
{
FILE *fin, *fout;
struct header au;
char path[10];
printf("Enter name of file to be processed: ");
scanf("%s", path);
fin = fopen(path, "r");
fout = fopen("out.au","w");
fscanf(fin, "%s %d %d %d %d %d", &au.magic, &au.offset, &au.size, &au.encoding, &au.rate, &au.channels);
printf("%s\n%d\n%d\n%d\n%d\n%d\n", au.magic, ntohl(au.offset), ntohl(au.size), ntohl(au.encoding), ntohl(au.rate), ntohl(au.channels));
}
我在报头值读数是否正确?