Re: strdup/strcpy

From: Brian (borlick@mines.edu)
Date: 11/07/02


Mark Garringer wrote:
>
> > > money types as well.  I fixed it with snprintf() . . .
> >That's a slight bit of overkill.  It should be sufficient to just do:
> >
> >       obj->name = strdup(currency_types[cur]);
>
> I must apologize. I didn't quite make myself clear enough. I also want to
> have the word "coins" in my name list, so when it's done there will be
> "coins euros" in the obj->name list. I can get one or the other but not
> both.

If you don't wish to maintain two separate arrays, one of the namelist
and
one of the currency short names, then Mathew's method would be easiest.
That is,

     snprintf(buf, sizeof(buf), "coins %s", currency_types[cur]);
     obj->name = strdup(buf);

Make sure to declare buf locally if you are using a recent version of
CircleMUD.

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT