Re: [NEWBIE]

From: George (greerga@CIRCLEMUD.ORG)
Date: 05/09/98


On Sat, 9 May 1998, Travis M. Fuller wrote:

>  sprintf(buf, "You are %d years old.", GET_AGE(ch));    <--------------
>this doesnt print
[...]
>if (GET_LEVEL(ch)>=10)
>   sprintf(buf, "Str: [%d/%d]  Int: [%d]  Wis: [%d]  "
>   "Dex: [%d]  Con: [%d]  Cha: [%d]\r\n",
>   GET_STR(ch), GET_ADD(ch),
[...]

You're not appending to the string, you're overwriting it with that.

>sprintf(buf,
>       "%sYou have %d(%d) hit, %d(%d) mana and %d(%d) movement points.\r\n",
>   buf, GET_HIT(ch), GET_MAX_HIT(ch), GET_MANA(ch), GET_MAX_MANA(ch),
>   GET_MOVE(ch), GET_MAX_MOVE(ch));

This is the current way CircleMUD uses to append.

It's better to do:

sprintf(buf + strlen(buf), "blah blah", blah blah);

--
George Greer, greerga@circlemud.org | Genius may have its limitations, but
http://patches.van.ml.org/          | stupidity is not thus handicapped.
http://www.van.ml.org/CircleMUD/    |                  -- Elbert Hubbard


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



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