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 -- 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