我在这里有一个示例代码:
unsigned char *m_fbytes;
m_fbytes = (unsigned char*)malloc(m_iByteLen1FrameDecoded*sizeof(short));
int err;
err = fread(m_fbytes, sizeof(short), 960, fin);
curr_read = err;
for(int i=0;i<curr_read;i++)
{
opus_int32 s;
s=m_fbytes[2*i+1]<<8|m_fbytes[2*i];
s=((s&0xFFFF)^0x8000)-0x8000;
m_in[i]=s;
}
int iLen = encode(m_enc, m_in, m_iByteLen1FrameDecoded, m_data, m_max_payload_bytes);
我不明白这一行:
err = fread(m_fbytes, sizeof(short), 960, fin);
这段代码的作者读取了一些字节(又名无符号字符),但他们通过了 sizeof(short)。
他们为什么使用“sizeof(short)”?