Re: Who MOTD

From: George Greer (greerga@circlemud.org)
Date: 11/08/01


On Fri, 9 Nov 2001, Ramsey Stone wrote:

>(NEAR THE TOP)
>+char *whomessage;
>
>(In ACMD(do_who), near the end)
>+sprintf(buf + strlen(buf), "&R[&r%s&R]&n\n", *whomessage);
>
>+ACMD(do_whomessage) {
>+one_argument(argument, arg);
>+*whomessage = arg;
>+}

Four infractions:

1) Global variable will be for _everybody_, not just one person.  You want
   the pointer in 'struct char_data' or 'struct descriptor_data'.

2) You want 'whomessage', not '*whomessage'.  You're assigning a pointer,
   not writing to what the pointer goes to.

3) You need to allocate memory for that string.  'arg' is a magical global
   buffer that is used for many different functions.

4) Failure to grasp C.  (To put it bluntly.)  Best solution there is a good
   C book and a lot of quiet reading.  It'll make more sense then.

--
George Greer
greerga@circlemud.org

--
   +---------------------------------------------------------------+
   | 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/06/01 PST