On Tue, 5 Nov 1996, Brian Williams - Nashak wrote:
> Okay.. here is my problem, I added an attributes command, and a new score
> thing.. anyways.. here is the problem.. I type att.. it says all the stuff
> fine except for one thing, the top line:
> C Craraererttttbubus s r r shsh
> should be
> Character attributes for Nashak
> and
> ScSce e fofoatatn n r r shsh
> should be
> Score information for Nashak
> my code is as follows:
>
> ACMD(do_attributes)
> {
> sprintf(buf, " Character attributes for %s\r\n",
> GET_NAME(ch));
> sprintf(buf, "\r\n%sLevel: %d Race: %s Class: %s\r\n", buf,
^^
Your problem is here that %s is placing what is already in the
char string buf, into the current format. That %s needs to be at the
beginning of the format line or you get the garbage you referred to above.
The line should look like below:
sprintf(buf, "%s\r\nLevel: %d Race: %s Class: %s\r\n", buf,
^^ (with the %s here)
> GET_LEVEL(ch),
> RACE_ABBR(ch), CLASS_ABBR(ch));
> sprintf(buf, "%sAge: %d yrs / %d mths Height: %d inches Weight: %d
> lbs\r\n", buf,
> age(ch).year, age(ch).month, GET_HEIGHT(ch), GET_WEIGHT(ch));
> if (GET_CLASS(ch) == CLASS_WARRIOR && GET_STR(ch) == 18)
> sprintf(buf, "%sStr: %d/%d Int: %d Wis: %d\r\nDex: %d
> Con: %d Cha: %d",
> GET_STR(ch), GET_ADD(ch), GET_INT(ch), GET_WIS(ch),
> GET_DEX(ch), GET_CON(ch), GET_CHA(ch));
> else
> sprintf(buf, "%sStr: %d Int: %d Wis: %d\r\nDex: %d
> Con: %d Cha: %d",
> GET_STR(ch), GET_INT(ch), GET_WIS(ch), GET_DEX(ch),
> GET_CON(ch), GET_CHA(ch));
> sprintf(buf, "%sArmor Class: %d\r\n", buf, GET_AC(ch));
> sprintf(buf, "%sHitroll: %d Damroll: %d\r\n", buf, (ch)->points.hitroll,
> (ch)->points.damroll);
> sprintf(buf, "%sAlignment: %d\r\n", buf, GET_ALIGNMENT(ch));
> sprintf(buf, "%sSaving Throws: PAR[%d] ROD[%d] PET[%d] BRE[%d]
> SPE[%d]\r\n", buf,
> GET_SAVE(ch, 0), GET_SAVE(ch, 1), GET_SAVE(ch, 2),
> GET_SAVE(ch, 3),
> GET_SAVE(ch, 4));
> }
>
> ACMD(do_score)
> {
> struct time_info_data playing_time;
> struct time_info_data real_time_passed(time_t t2, time_t t1);
>
> sprintf(buf, " Score information for %s\r\n", GET_NAME(ch));
> sprintf(buf, "\r\n%sLevel: %d Race: %s Class: %s Sex: ", buf,
^^ (same problem here)
Just move that %s to the beginning of the format string and your
problem should be solved.
Michael Scott -- "Living in the Eye of the Hurricane."
FLAMES/COMMENTS to scottm@workcomm.net
+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://cspo.queensu.ca/~fletcher/Circle/list_faq.html |
+-----------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/18/00 PST