Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: By the way, here is an instance where crafty's node counts truncate

Author: Robert Hyatt

Date: 18:48:04 09/26/99

Go up one level in this thread


On September 26, 1999 at 18:29:37, David Eppstein wrote:

>On September 26, 1999 at 16:25:44, Robert Hyatt wrote:
>>On September 26, 1999 at 14:07:03, Heiner Marxen wrote:
>>>Say, you want at most 8 such conversions to be used
>>>in one printf (between 2 sequence points).  Just use an 8-element array
>>>of such static string buffers, with a static index for the next to use
>>>element, cyclically walking through the 8 buffers.  I've done that,
>>>and found it to be a great help.
>>>
>>>Sometimes I've used "double" for counters to achieve 53 bits of integer
>>>precision, and print them with "%.0f".
>>>
>>>Heiner
>>
>>it would work, but it is a very sloppy programming approach.  IE imagine what
>>happens when you use this  piece of code to display more than 8 values at one
>>time when you are debugging one day. And you forget that you have that 8 number
>>limit, and spend a lot of time debugging something that isn't a bug, because the
>>output is corrupted...
>>
>>as the saying goes, "been there, done that, but _not_ doing it tomorrow..."
>
>In two messages in the same thread you are saying you want to avoid sloppy
>unsafe programming practices, and also saying you want to use sprintf???
>
>(Hint: it has no protection against buffer overflows.)


I don't need protection against buffer overflows.  I code for that circumstance
up front.  :)

I don't want functions that behave in bizarre ways because of static memory
saved across calls, however..

gets() was always bad because you couldn't control how many bytes.  With
sprintf() you can control the output and not worry about overwriting any max
buffer length...



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.