Author: Uri Blass
Date: 09:32:53 11/22/04
Go up one level in this thread
On November 22, 2004 at 12:06:16, Dieter Buerssner wrote:
>Uri, I cannot fully understand. First of all, using a global buffer seems wrong,
>or at least fragile, when the function you use the buffer in can be interrupted
>by another function that uses the same buffer.
Crafty is using buffer as a global variable and if I understand correctly it use
it both for getting winboard commands and for creating book.
>
>Then I don't understand why you use scanf for reading PGN? scanf reads from
>stdin, not from a disk file.
The scanf was used before reading the pgn in order to read parameters from the
user about the book(maximal ply and minimal frequency)
Here is the function that it is used.
Note that Print is function that practically does slightly more than printf
including printing to the log file if the log is enabled
void createbookcommand(void)
{
int max_dep,min_fre;
Print("enter max ply\n");
scanf("%d",&max_dep);
Print("enter min frequency\n");
scanf("%d",&min_fre);
checkup();
Print("start creating book");
translating(max_dep,min_fre);
}
void Print(const char *szFormat, ...)
{
va_list vargs;
va_start(vargs, szFormat);
vprintf(szFormat, vargs);
fflush(stdout);
if (g_bLogging && logmovei != (FILE *)NULL)
{
vfprintf(logmovei, szFormat, vargs);
fflush(logmovei);
}
va_end(vargs);
}
Did you mean sscanf of fscanf? (I see that you
>expicetly mentioned scanf and sscanf in your post). sscanf certainly should not
>touch stdin->_cnt.
As you can see I meant scanf.
Maybe I should not use it as the remarks that I deleted suggested but fgets get
a string and I wanted to get a number directly and not to get a string from the
user and translate it to a number.
Uri
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.