Cでコーディングしてからしばらく経ちましたが、奇妙なことが起こっています。誰かが私のコードを実行して、出力が同じかどうかを確認できるかもしれません。ゼロが印刷されていないようで、「データ出力」が印刷されていないようです。
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <io.h>
#include <conio.h>
void main(void)
{
int i;
long n;
FILE *wavFile;
printf("The data output \n\n\r");
wavFile = fopen("bigbrain.wav","rb");
while(feof(wavFile)==0)
{
i = getw(wavFile);
if(ferror(wavFile)!=0)
{
printf("\n an error has occured");
n = ftell(wavFile);
printf("\nThe value of n is %ld",n);
getch();
}
printf("%x",i);
}
n = ftell(wavFile);
printf("\n\The value of n is %ld",n);
fclose(wavFile);
printf("\n\nEnd of File");
getch();
}
これから得られる結果は次のとおりです。これは wave ファイルなので、そこにはゼロが含まれているはずです。誰かが何か間違っていると思いますか?
4646495212c524556415720746d6610100012b112b118
これは、そこにあるはずだとわかっているものを相互参照するだけで、手作業でデータを分解した方法です。
//Winamp says Unsigned 8-bit PCM; 1 channel; 11025Hz
46464952 //"RIFF"
12c52 //size: actuall size 76890, says 76882. My doc says correct because minus 8 bits for fields not included
45564157 //format "WAVE"
20746d66 //subchunkID 0x666d7420 but in big endian
10100012 //subchunk 1 size, expecting 16
b1 //audio format
1 //number of channels
2b11 //sample rate: file should be 11025 (ox2b11)
8000 //byte rate
//block align
1 //bits per sample... i think it cut off zero so 0x10 for 16
61746164 //start of data it's "data" 0x64617461 in big endian