Home > OS >  Cout trigger breakpoint when i try to print something which is not a string
Cout trigger breakpoint when i try to print something which is not a string

Time:07-31

I trying to build fft function in c . I realized there are errors in the process so I wanted to print each step on it's own. When I try to do cout to everything that is not a string it trigger a breakpoint and error: "A heap has been corrupted " In the main it sometimes and sometimes not Any help, or suggestions would be much appreciated. enter image description here

CodePudding user response:

You allocated dynamically arrays with len / 2 elements. But in for loops like this

for ( int i = 0; i <= len/2; i   )

you are trying to access len / 2 1 elements that results in undefined behavior. The valid range of indices is [0, len / 2 ).

You have to write

for ( int i = 0; i < len/2; i   )
  • Related