Thread: why a certain line is not being executed

  1. #16
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Try matsp's suggestion first. stdout is not supposed to be fully buffered when it refers to the command prompt's display, but it could somehow be fully buffered on your machine.

    By the way, if you notice in the code I posted, not only did I use the code formatting tool provided with Code::Blocks, but I commented out that first printf() so as to check if that is exactly what you compiled and tested with. Compile and test with the program I showed you. Perhaps tabstop is right: what you are testing with and what you are showing us could be different, so merely showing us what you showed us may not help.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  2. #17
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    the flush command work
    every thing is fine

    but the CMD box gives only part of the list

    how to fix it
    so it will show me all the output
    without any cmd limitation
    ??

  3. #18
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    but the CMD box gives only part of the list

    how to fix it
    so it will show me all the output
    without any cmd limitation
    ??
    You could try scrolling up, but eventually there is a line number limit that the command shell may impose. A workaround is to print everything on the same line so you can print more before that limit is reached. Alternatively, you print (or redirect output) to a file, then open that file in a text editor.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #19
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    how do i do output on a text file on
    code blocks 8.02

    ??

  5. #20
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    how do i do output on a text file on
    code blocks 8.02
    You can use the command prompt directly and then use output redirection (e.g., programname > filename.txt), or you can use file operations (e.g., fprintf instead of printf).
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Printing Length of Input and the Limited Input
    By dnguyen1022 in forum C Programming
    Replies: 33
    Last Post: 11-29-2008, 04:13 PM
  2. Unreachable code?
    By Leojeen in forum C Programming
    Replies: 15
    Last Post: 09-28-2008, 07:11 PM
  3. Finding carriage returns (\c) in a line
    By JizJizJiz in forum C++ Programming
    Replies: 37
    Last Post: 07-19-2006, 05:44 PM
  4. Adding Line numbers in Word
    By Mister C in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 06-24-2004, 08:45 PM