[Code] BUS Error...

From: Mark S. Reichman (mark@borg.com)
Date: 01/19/97


Ok, this is my first post. I am somewhat of an experienced C coder and have
been
killing myself over this simple problem.  Below in the sprintf() statement
I try
to add color to Puff's shouts.  As long as I keep it commented out, Puff
shouts fine.
If I uncomment the sprintf() line it will compile fine.  However, 
when Puff does shout the mud crashes with a "Bus-Error".  I have seen
color implemented this way throught the code.  Why is this wrong somehow?
Oh Dan, if this code looks familiar it because your post the other day
about "announce" is
exactly what I have been looking for.  Thanks.


SPECIAL(puff)
{
  struct descriptor_data *i;
  struct char_data *tch;
  char *mesg  = "\0";

  if (cmd || FIGHTING(ch) || GET_POS(ch) <= POS_SLEEPING)
    return (0);

  switch (number(0, 60)) 
  {
  case 0:
    mesg = "Puff shouts, 'Uh... Someone in this mud is gonna get their butt
kicked!'\r\n";
    break;
  case 1:
    mesg = "Puff shouts, 'You and me.  Its go time!'\r\n";
    break;
  case 2:
    mesg = "Puff shouts, 'Hey you. Yeah you! I eat players for lunch!'\r\n";
    break;
  case 3:
    mesg = "Puff shouts, 'Yo Mama must of made love to an orc!'\r\n";
    break;
  case 4:
    mesg = "Puff shouts, 'Is that a sword or are you just happy to see
me?'\r\n";
    break;
  case 5:
    mesg = "Puff shouts, 'Are you lookin at me?  Do you know what I do to
players that look at me?'\r\n";
    break;
  case 6:
    mesg = "Puff shouts, 'There's not enough room in this mud for the both
of us!'\r\n";
    break;
  default:
    return (1);
    break;
  }

/*  sprintf(mesg,"%s%s%s",CCYEL(ch, C_NRM),mesg,CCNRM(ch, C_NRM)); */ 

  for (i=descriptor_list; i; i=i->next)
    if (!i->connected && (tch = i->character) &&
    world[tch->in_room].zone == world[ch->in_room].zone &&
    !PLR_FLAGGED(tch, PLR_MAILING) && 
    !PLR_FLAGGED(tch, PLR_WRITING))
    send_to_char(mesg, tch);
  return (1);
}

***********************************************************************
"On two occasions I have been asked [by members of Parliament!], 
'Pray, Mr. Babbage, if you put into the machine wrong figures,
will the right answers come out?'  I am not able rightly to apprehend
the kind of confusion of ideas that could provoke such a question."
                         -- Charles Babbage

Mark S. Reichman  mark@borg.com    
***********************************************************************
+-----------------------------------------------------------+
| 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