Date and Time

This is a discussion on Date and Time within the C Programming forums, part of the General Programming Boards category; Ok, thanks P.S. That's why it is so recomended to put '\n' at the end of the printf statement......

  1. #16
    Banned
    Join Date
    May 2003
    Posts
    124
    Ok, thanks
    P.S. That's why it is so recomended to put '\n' at the end of the printf statement...

  2. #17
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by AProg
    Ok, thanks
    P.S. That's why it is so recomended to put '\n' at the end of the printf statement...
    Um no. Only if you want a new line on your screen. Otherwise don't.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #18
    Un Artiste Extraordinaire volk's Avatar
    Join Date
    Dec 2002
    Posts
    357
    Originally posted by Prelude

    Because there's no newline character printed and no call to fflush, the string may be placed in a temporary buffer because calling a low level write function to place the string directly onto stdout can be expensive.
    What do you mean by "may"? What causes this "may" to occur?

    Is it like a 50/50 thing? You'd think computers would be more exact.
    Last edited by volk; 06-09-2003 at 07:51 PM.

  4. #19
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    >What do you mean by "may"? What causes this "may" to occur?
    >Is it like 50/50 thing? You'd think computers would be more exact.

    It depends on the host environment. Take a tiny example.
    Code:
    #include <stdio.h>
    int main(void)
    {
       printf("Press any key to continue...");
       getchar();
       return 0;
    }
    I build this and run it in Visual SlickEdit's Build shell and I get a blank stare (no prompt). On the same machine I run it in a regular Windows command shell and I see the prompt. Same machine, same binary -- different hosts (can) do different things.

    "May" means the programmer didn't bother to ensure that a prompt should be seen - it was left up to the host to decide. If the programmer can't afford "may", then it's up to the programmer to be more exact.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  5. #20
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,161
    Hmm.... I always thought that exiting a program automatically flushed all bufferes. Obviously there are some systems where thist is not true. I consider that very wierd, and non-friendly.
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Advancing day by day until it matches a second date
    By nhubred in forum C++ Programming
    Replies: 1
    Last Post: 05-30-2009, 09:55 AM
  2. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 04:25 PM
  3. How to get and set windows time and date
    By huwan in forum Windows Programming
    Replies: 18
    Last Post: 05-13-2008, 11:33 AM
  4. Sending an email in C program
    By Moony in forum C Programming
    Replies: 28
    Last Post: 10-19-2006, 11:42 AM

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