This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: localtime


On Wed, 15 Jun 2011, Tod wrote:

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?

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?

tout is a char *, so sizeof(tout) in getTime() will be 4 or 8. You will need to change the calling sequence of getTime() to pass the length of tout, which will depend on how you allocated it:


	char tout[128];
	getTime(tout,sizeof(tout));

or
	char *tout = malloc(128);
	getTime(tout,128);

etc.

Steve

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]