Re: Get local date / hour



On Mon, 2006-03-13 at 16:55 -0600, Bob Caryl wrote:
> Paul Davis wrote:
> 
> >just a quick heads up: the memset is unnecessary and strftime(3) is more
> >portable. 
> >  
> >
> 
> Hey Paul,
> 
> Different strokes, ok?  I've been writing "C" programs for over 20 years 
> and old habits die hard.  I initialize every variable I declare inside a 
> function (even if that variable is NOT on the stack)  whether it needs 

your sprintf call initializes it again. in both cases, you have a
function call doing variable initialization, not an assignment
operation. that's all i meant by unnecessary. if i'm going to continue
with my hated assignment as language lawyer, i would note my own feeling
that sprintf() should never ever be used; snprintf() is vastly safer.
now shoot me :)

> it or not.  And, since strftime(3) uses the same structure (struct tm) 
> that I did to create my string, what makes it "more portable"?

in this particular case nothing. but a minor tweak of this function
could lead to a case where locale should be taken into account and is
not.

sorry for being a language lawyer.

--p





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]