A funny thing happened to me this morning. The following code caused my
computer to crash when compiled under TC++3.0, BC++4.0 and BC++4.5:
#define FFT_SIZE 4096
int encoded_frequency = 0;
while(encoded_frequency != -1)
printf("Enter input Frequency (Hz):");
for(loop=0; loop < FFT_SIZE; loop++)
dummy = 2 * PI * encoded_frequency * loop / 8000.0;
input_waveform[loop] = sin(dummy);
decoded_frequency = ctcss_decode(input_waveform);
decoded_frequency *= 8000 / (float)(FFT_SIZE);
printf("Entered Frequency: %dHz\n",encoded_frequency);
printf("Detected Frequency: %dHz\n",decoded_frequency);
However when I changed the input_waveform definition to a static (shifting
it from the stack to global memory space IMHO) the problem was fixed.
Obviously it is crazy to put 4k arrays on the stack on a PC, but I was
under the impression that my friendly borland compiler would tell me that it
did not have the space to hold this array, instead of just crashing.
Can anyone shed some light on this? Just for the record I tried compiling
the code under all available memory models.
Thanks in advance,