printf() question

This is a discussion on printf() question within the C Programming forums, part of the General Programming Boards category; Hi there. I'm writing a program that makes huge amounts of calculations without user's interference. So I wrote in the ...

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    20

    Question printf() question

    Hi there.

    I'm writing a program that makes huge amounts of calculations without user's interference.

    So I wrote in the code some printf() just to know when it's doing what.

    For example, when it's going to read some big matrix from a file, it was suposed to print on screen something like "Reading the matrix", but it don't really happen.

    It prints everything at the end...

    My question is: why those printf commands that comes before in the code runs after?

    Thanks.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    Make sure the strings end with a newline, or call fflush on stdout. It sounds like the stream isn't getting flushed when you want it to.
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    20
    Quote Originally Posted by Prelude View Post
    Make sure the strings end with a newline, or call fflush on stdout. It sounds like the stream isn't getting flushed when you want it to.
    Thanks.

    I'll try that right away!

  4. #4
    Registered User
    Join Date
    Jan 2008
    Posts
    20
    Quote Originally Posted by Prelude View Post
    Make sure the strings end with a newline, or call fflush on stdout. It sounds like the stream isn't getting flushed when you want it to.
    Thanks again.

    That turned out to be exactly the case!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with a C Programing Quiz project
    By dilemma in forum C Programming
    Replies: 12
    Last Post: 05-15-2009, 03:35 PM
  2. IF CONDITION plese help
    By birumut in forum C Programming
    Replies: 12
    Last Post: 03-06-2009, 08:48 PM
  3. I have some questions :(
    By geekrockergal in forum C Programming
    Replies: 19
    Last Post: 02-01-2009, 08:44 AM
  4. saying hello and 1st question
    By darksys in forum C Programming
    Replies: 12
    Last Post: 10-31-2008, 02:58 PM
  5. fgets question
    By Ash1981 in forum C Programming
    Replies: 12
    Last Post: 01-12-2006, 08:53 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21