home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c      Meh, in C you gotta define EVERYTHING      243,242 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 242,770 of 243,242   
   Kenny McCormack to All   
   printf and time_t   
   05 Jan 26 07:19:02   
   
   From: gazelle@shell.xmission.com   
      
   Here's kind of an old chestnut...   
      
   The question is: How can you reliably printf() a time_t value?   
   What conversion spec should you use?   
      
   The answer seems to be: try stuff until the compiler doesn't warn.   
      
   Note that there is now %z for size_t, but there really should be a "Just do   
   the right thing - you're the compiler, you know what type the arg is, do   
   the right thing" spec.   
      
   It turns out that in my use case, %lu works, but how can you know?   
   Note, BTW, that another way to do it is to use %d and case the time_t value   
   to (int), but that seems kludgey.   
      
   --   
       Nov 4, 2008 - the day when everything went   
       from being Clinton's fault to being Obama's fault.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca