ctime adds \n

This is a discussion on ctime adds \n within the C Programming forums, part of the General Programming Boards category; why in the hell would they do this? it makes no sense to add a newline character, but yet it ...

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    2,144

    ctime adds \n

    why in the hell would they do this? it makes no sense to add a newline character, but yet it is the defined behavior of this (and other unix-type time functions). I think it would have been much more flexible if it did not add the \n character. it would make a lot more sense to add one if needed, rather than strip it off if it is unwanted.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I agree, but it happens to be the way that is was specified originally, so changing it would potentially break existing code.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    2,144
    I guess this is a case of "what were they smoking?" after all, it was the late 60's and early 70's when all of this was created....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Classes in C++
    By Kool4School in forum C++ Programming
    Replies: 22
    Last Post: 01-21-2009, 08:26 PM
  2. why only the succeeding value adds up???
    By omarbags in forum C Programming
    Replies: 18
    Last Post: 01-01-2009, 01:28 PM
  3. Replies: 5
    Last Post: 09-26-2006, 01:51 PM
  4. time precision (ctime), tm struct question
    By cjschw in forum C++ Programming
    Replies: 1
    Last Post: 12-26-2003, 12:51 PM
  5. ctime() error...implementation maybe?
    By [EMOBA] in forum C++ Programming
    Replies: 2
    Last Post: 09-26-2002, 03:57 PM

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