Menu

#642 output of program depends on code that should have no effect

open
nobody
None
5
2012-09-26
2006-05-13
Anonymous
No

I am testing an algorithm that I cut and pasted out
of the book "Numerical Recipes in C" which should be
guaranteed bug free, however it wasn't
working...until I added a printf statement to line#
207 inside a for(;;) loop in the routine bsstep
(...). It doesn't matter what is printed--printf
("");--works just as well as printf("hello world");
If you comment out the printf statement, however, the
program will no longer work. Reinstalling Dev C++
didn't affect it. I have not tried running it with
Dev C++ 4.0.

The program should print the results:

result = 5.000000e+000
result = 5.400361e-002
Press any key to continue . . .

After commenting out line# 207 //printf(""); the
results are:

result = 5.000000e+000
...(the program gets stuck)

strange bug :)

Discussion

  • Nobody/Anonymous

    program "I like it when you use printf statements"

     
  • Nobody/Anonymous

    Logged In: NO

    First, this isn't a bug within Dev-Cpp. It seems this is a
    Problem with your code or g++. If I compile your source with
    -g3 -march=i386 (or Project Options, Compiler, Code
    Generation: i386) it runs without the "207 printf".
    Best regards, Andy

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.