[NEWBIE][CODE] Stupid Buffer Thing

From: Edward Felch (dustlos@hotmail.com)
Date: 06/25/01


OK, this is really silly, for reference, who, user, etc works. But... this
function seems to like making things odd. I have tried variations of
different buffers, making new char temp_buf[MAX_INPUT_LENGTH]; etc, also
tried using sprintf(buf+strlen(buf) for other parts but it always garbles at
least some text. This feels ridiculous to me :-/ please give a bit of
advice, something bla happened here, thanks for any help! All the strings
used here exist and work right, so it isnt that at least...

Output:
memberslis <- should be Nae' Blis members
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Sponsor Dust

Members: 1 Member Rank: 1
Power: 110 Power Rank: 1

Code:
void show_clan_who(struct char_data *ch, struct clan_type *clan)
{
  struct descriptor_data *d;
  struct clan_type *cptr = NULL;
  int power_r = 1, member_r = 1;
  int i;

  *buf = '\0';
  sprintf(buf, "%s members\r\n", clan->name);
  send_to_char(buf, ch);
  sprintf(buf, "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\r\n");
  send_to_char(buf, ch);
  for ( d = descriptor_list; d; d = d->next ) {
    if ( !(d->connected) && (GET_CLAN(d->character) == GET_CLAN(ch))) {
      sprintf(buf, "%s %s\r\n",
clan->rank_name[GET_CLAN_RANK(d->character)], GET_NAME(d->character));
      send_to_char(buf, ch);
    }
  }
  for (cptr = clan_info; cptr; cptr = cptr->next) {
    if (cptr == clan)
      continue;
    if (cptr->members > clan->members)
      member_r++;
    if (cptr->power > clan->power)
      power_r++;
  }
  sprintf(buf, "\r\nMembers: %d Member Rank: %d\r\nPower: %d Power Rank:
%d\r\n",
          clan->members, member_r, clan->power,  power_r);
  send_to_char(buf, ch);
  return;
}
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/05/01 PST