This is the mail archive of the
mailing list for the Cygwin project.
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.
Its been a number of years so I'm a little rusty. Thanks all.
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple