Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: about a bug in calculating perft during reading pgn

Author: Dieter Buerssner

Date: 09:43:36 11/22/04

Go up one level in this thread


On November 22, 2004 at 12:32:53, Uri Blass wrote:

>void createbookcommand(void)
>{
>	int max_dep,min_fre;
>	Print("enter max ply\n");
>	scanf("%d",&max_dep);
>	Print("enter min frequency\n");

You have to type in the number and return.

>	scanf("%d",&min_fre);

return will stay in the input buffer after this scanf.

>	checkup();
>	Print("start creating book");
>	translating(max_dep,min_fre);
>}

And later, input_available will return true, because there still is input
available (the return you typed after the number). I guess, now you read some
lines into buffer - then get interrupted (in the middle of the processing of one
line) because you only later detect the return. Now you overwrite the same
buffer. A local buffer would hide the problem (actually it would not be there).
IMHO, it would be better to use fgets and perhaps sscanf. Easier error checking
is possible with strtol.

Still, if you hit the keyboard during processing of the PGN, you'd see the same
problem (because of the global buffer - so change to a local buffer).

Regards,
Dieter






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.