X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Message-ID: <4DF901C3.7070204@gmail.com> Date: Wed, 15 Jun 2011 15:02:27 -0400 From: Tod User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: localtime 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> <62E96F23-86D9-4C60-AE4C-BA3BC2FD49D3 AT bitmover DOT com> In-Reply-To: <62E96F23-86D9-4C60-AE4C-BA3BC2FD49D3@bitmover.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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