printf dont print anything

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    printf dont print anything

    Around 3 years ago I got a problem. It was interesting for me, so I solved it. Compiler was turbo C/c++ 3.0. That is very old compiler.

    That program had very poor memory management as I can recall(I dont have the source code right now). It used recursive function(to implement backtracking). The problem was after running the entire program the result(not display) used generated correctly(check ed thousand time by debugging) but when i tried to print that array I never saw any output in the display.

    I can guess stupid memory management has to do something with it. I actually wanna know what can be possible mistake where printf function wont print anything.
  • donbock
    Recognized Expert Top Contributor
    • Mar 2008
    • 2427

    #2
    In general, if nothing comes out when you call printf() the likely problems are:
    • stdout usually [always?] defaults to buffered I/O. This means that printf output goes into a memory buffer. To get the output out of the buffer and onto the monitor screen you either have to call a flush function or you need to print a newline character. This is by far the most common problem I've seen.
    • The format string is not consistent with the variable argument list. However, this error is more likely to result in garbage output than no output.
    • Something is wrong with the device driver associated with stdout.
    • Something is wrong with the connection between the computer and the monitor associated with stdout.
    • Something is wrong with the monitor associated with stdout.

    printf has a return value indicating whether it thinks it succeeded or failed. You can check the return value -- it can help with the debugging to know whether printf is aware of a problem.

    Comment

    • Banfa
      Recognized Expert Expert
      • Feb 2006
      • 9067

      #3
      How about some redirected stdout to an alternate device without you being aware.

      Comment

      • johny10151981
        Top Contributor
        • Jan 2010
        • 1059

        #4
        All of your answers make lot of sense. I was using simple desktop computer with one output device(crt monitor), Intel Pentium III processor with intel mother board. Installed OS was windows XP, I can recall.

        Comment

        Working...