Re: Source for Scoreboard

From: Andrew Ritchie (object@alphalink.com.au)
Date: 03/03/99


>This source will compile, and when I run the command, I will recieve only the
>output
>entered at the beginning (the *'s, Rhu-Dina'ar Automatic Scoreboard, etc...),
>I have yet
>to see any scores printed...
>
>Any suggestions ?
>Am I making a stupid mistake ?

Some might call it stupid, but it's a mistake commonly made by inexperienced
coders. Whenever you call the sprintf() function, you are overwriting the
data stored in the variable 'buf', and replacing it with the new data, not
appending it to the end of the string. For example:

sprintf(buf, "Hi there");
sprintf(buf, "My name is Fred");

The variable 'buf' would now only contain the string, "My name is Fred"
because it overwrites what was previously stored. There are two simple
methods of getting around this:

sprintf(buf, "Hi there");
sprintf(buf + strlen(buf), "My name is Fred");

OR

sprintf(buf, "Hi there");
strcat(buf, "My name is Fred");

Both these examples would _append_ data to buf, not overwrite it. That is
why you are only getting a little bit of information when you type the
command. Hope this helps.

---
Andrew Ritchie,
object@alphalink.com.au.


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST