X-Recipient: archive-cygwin@delorie.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
Date: Wed, 15 Jun 2011 14:43:03 -0400 (EDT)
From: Steve Thompson <smt@vgersoft.com>
To: cygwin@cygwin.com
Subject: Re: localtime
In-Reply-To: <4DF8F426.7040705@gmail.com>
Message-ID: <alpine.LRH.0.9999.1106151440190.8672@helios.vgersoft.com>
References: <4DF8CF3D.40104@gmail.com> <4DF8EA79.2060404@gmail.com> <20110615173847.GB23078@ednor.casa.cgf.cx> <4DF8EF9F.4090906@gmail.com> <20110615174805.GC23078@ednor.casa.cgf.cx> <4DF8F426.7040705@gmail.com>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

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

