Re: [NEWBIE] Clan.txt patch

From: Patrick J. Dughi (dughi@IMAXX.NET)
Date: 04/20/98


> In a patch I found I'm having a slight problem. I've clipped the part that
> is troubling me:

> void do_clan_info (struct char_data *ch, char *arg)
> {
> int i=0,j;
> int k=1;

>   for(i=0; i < num_of_clans; i++)
>     sprintf(buf, "%s%s[%-3d]%s  %-20s %sMembers:%s %3d  %sPower:%s %5d
> %sAppfee:%s %d\r\n",
>                         buf , CCLBL(ch,C_NRM), k, CCYEL(ch,C_NRM),
> clan[i].name,
>                         CCGRN(ch,C_NRM), CCNRM(ch,C_NRM), clan[i].members,
> CCGRN(ch,C_NRM),
>            CCNRM(ch,C_NRM), clan[i].power, CCGRN(ch,C_NRM),
> CCNRM(ch,C_NRM), clan[i].app_fee);
> -----------END SNIP---
>
> What is happening is the clan id number is doubling, and it isn't starting
> with 0. I created 2 test clans and typed: clan info and this is the result:
>
> Clan Info
> ----------------------------------------------------------------------------
> [1  ]  clan             Members:   0  Power:     0  Appfee: 0
> [1  ]  Test             Members:   1  Power:     1  Appfee: 0
>
        1) You may want to pick up a book on how to write c programs. This
isn't just a novice-level error which you have shown us, this is, quite
literally, the most simplistic problem I've ever had the misfortune of
seeing, especially though, on a mailing list.

        2) Here's how to fix it:

        Up in that printf function, replace the 'k' with 'i+1'. You're not
incrementing k, you're using i as the number, so may as well just
duplicate it. You can also remove the declaration of 'int k=1', up above,
unless it is somewhere used later (doubt it).

                                        PjD


     +------------------------------------------------------------+
     | 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