Hrm, As-is, this is seg faulting.
The first attempt in bfield.dat to use tmp is Mostkname:
#Battlefield Data
Totalkill 100
Totalbf 10
Racekill 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007
Classkill 1 2 3 4 5
Mostkname Evangelion~
...
GDB reports:
Program received signal SIGSEGV, Segmentation fault.
fread_string (fp=0x80efa70) at db.c:2834
2834 if ((*plast++ = c) == '~')
(gdb) bt
...
#0 fread_string (fp=0x80efa70) at db.c:2834
#1 0x08068e52 in bfield_init (fp=0x80efa70) at bfio.c:230
(continues, but irrelevant)
...
Line 230 of bfio.c is: tmp = fread_string (fp);
I assign tmp as: char *tmp; at the top of bfield_init.
Relatedly, Mostkname is saved to the file like this:
fprintf(fp, "Mostkname %s~\n", bfield_data.most_kills.name);
I'm not sure why it's faulting.
----- Original Message -----
From: "Jeremy Hill" <[EMAIL PROTECTED]>
To: "Michael Barton" <[EMAIL PROTECTED]>
Cc: <[email protected]>
Sent: Thursday, July 11, 2002 11:50 PM
Subject: Re: reading from files, fread_string
> Ok.
>
> if (!str_cmp (word, "Bestname"))
> {
> tmp = fread_string (fp);
> strcpy (bfield_data.best_ratio.name, tmp);
> free_string (tmp);
> fMatch = TRUE;
> break;
> }
>
> Correct?
>
> Can I then use tmp again at a different point without running into trouble?
> I.E. later:
>
> if (!str_cmp (word, "Mostkname"))
> {
> tmp = fread_string (fp);
> strcpy(bfield_data.most_kills.name, tmp);
> free_string(tmp);
> fMatch = TRUE;
> break;
> }
<snip>