即使printf不起作用,此代碼中出現了什麼問題。但它正在編譯這段代碼有什麼問題?事件printf未被打印
#include <speex/speex.h>
#include <stdio.h>
#include <stdlib.h>
/*The frame size in hardcoded for this sample code but it doesn't have to be*/
#define FRAME_SIZE 160
int main()
{
printf("decoding");
char *outFile;
FILE *fout, *fs;
short out[FRAME_SIZE];
float output[FRAME_SIZE];
char cbits[200];
int nbBytes;
void *state;
SpeexBits bits;
int i, tmp;
fout = fopen("test_40khz_mono_Q5.spx", "rb");
if(fout == NULL){
printf("******Error*******");
}
else{
printf("*******Okay********");
}
fs = fopen("pcmfile","wb");
if(fs == NULL){
printf("****Error pcm creation****");
}
else{
printf("*****pcm File created*****");
}
state = speex_decoder_init(&speex_nb_mode);
tmp=1;
speex_decoder_ctl(state, SPEEX_SET_ENH, &tmp);
speex_bits_init(&bits);
while (!(feof(fout)))
{
fread(&nbBytes, sizeof(int), 1, fout);
fread(cbits, 1, nbBytes, fout); //Problem area
speex_bits_read_from(&bits, cbits, nbBytes);
speex_decode(state, &bits, output);
for (i=0;i<FRAME_SIZE;i++)
out[i]=output[i];
fwrite(out, sizeof(short), FRAME_SIZE, fs);
}
speex_decoder_destroy(state);
speex_bits_destroy(&bits);
fclose(fout);
fclose(fs);
return 0;
}
有3個printf's。請問一個真正的問題。通過刪除所有不會導致問題的信號來清理你的例子。留下最小的部分,我會更有興趣看看它。 – 2011-01-27 12:42:53
爲這些診斷性`printf`添加一些換行符 - 它們可能被成功調用,但直到緩衝區已滿,它們纔會真正到達屏幕,您調用fflush或者打印換行符,添加新行然後告訴我們在哪裏它得到 – tobyodavies 2011-01-27 12:45:01