Author: Uri Blass
Date: 23:22:17 11/22/04
Go up one level in this thread
On November 22, 2004 at 12:43:36, Dieter Buerssner wrote:
>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.
Thanks
Here is my new function and I hope it is better.
void createbookcommand(void)
{
int max_dep,min_fre;
char *stopst;
char st[128];
int converted=0;
Print("enter max ply\n");
do
{
fgets(st, 128, stdin);
max_dep= strtol( st, &stopst, 10 );
}
while (max_dep<=0);
Print("enter min frequency\n");
do
{
fgets(st, 128, stdin);
min_fre= strtol( st, &stopst, 10 );
}
while (min_fre<=0);
Print("start creating book");
translating(max_dep,min_fre);
}
>
>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).
Not so simple because that buffer is used in more than one file.
It is used both in input.cpp and in createbook.cpp
The function copypgntoarray is part of create book and it is using the
information in buffer that is calculated in input.cpp(it is calculated by
functions that are releavent not only to create book but also to the function
that calculates the sum of perft on pgn file when copypgntoarray is relevant
only to creating the book).
Regards,
Uri
>
>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.