delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-SWARE-Spam-Status: | No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD |
X-Spam-Check-By: | sourceware.org |
Subject: | Re: localtime |
Mime-Version: | 1.0 (Apple Message framework v1084) |
From: | Georg Nikodym <georgn AT bitmover DOT com> |
In-Reply-To: | <4DF8F426.7040705@gmail.com> |
Date: | Wed, 15 Jun 2011 14:46:00 -0400 |
Cc: | cygwin AT cygwin DOT com |
Reply-To: | cygwin AT cygwin DOT com |
Message-Id: | <62E96F23-86D9-4C60-AE4C-BA3BC2FD49D3@bitmover.com> |
References: | <4DF8CF3D DOT 40104 AT gmail DOT com> <4DF8EA79 DOT 2060404 AT gmail DOT com> <20110615173847 DOT GB23078 AT ednor DOT casa DOT cgf DOT cx> <4DF8EF9F DOT 4090906 AT gmail DOT com> <20110615174805 DOT GC23078 AT ednor DOT casa DOT cgf DOT cx> <4DF8F426 DOT 7040705 AT gmail DOT com> |
To: | Tod <listacctc AT gmail DOT com> |
X-IsSubscribed: | yes |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
X-MIME-Autoconverted: | from quoted-printable to 8bit by delorie.com id p5FIkKJx030325 |
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
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |