localtime

Tod listacctc@gmail.com
Wed Jun 15 19:02:00 GMT 2011


On 06/15/2011 2:46 PM, Georg Nikodym wrote:
>
> On 2011-06-15, at 2:04 PM, Tod wrote:
>
>> Ok, right - duh.  Let me back up a couple of steps.
>>
>> I'm passing a 128 byte char array.  I allocated it to provide enough room for the date/time stamp this function is returning.  strlen(tout) will resolve to the length of the tout string.
>>
>> You said above that I shouldn't be using strlen(tout) and instead I should be passing 128.  Would I be better off using sizeof(tout) instead?
>
> Answered by Steve Thompson.
>
>> Also, the code has always worked.  I just recompiled it recently.  Now the date works but the time isn't appearing.  What could be causing that?
>
> It worked by accident, not by design.  strlen simply counts bytes until it sees a zero.  In previous runs you were lucky that the memory pointed to by tout didn't have a zero in the first N bytes where N was enough to hold the result from strftime().
>
> None of this is a cygwin issue.  Just very basic C programming.
>
> -g
>
>


Its been a number of years so I'm a little rusty.  Thanks all.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list