Re: [CODE] do_say #2

From: George (greerga@CIRCLEMUD.ORG)
Date: 04/05/98


On Mon, 6 Apr 1998, Benjamin Draper wrote:

>       case '?':
>           sprintf(buf1, "ask");
>           break;
>       case '!':
>           sprintf(buf1, "exclaim");
>           break;
>       default:
>           sprintf(buf1, "say");
>           break;
>       }

Using:
const char *buf1;

case '?': buf1 = "ask"; break;
case '!': buf1 = "exclaim"; break;
default: buf1 = "say"; break;

Little faster, uses less memory, and zero chance of overrun.
(Although this way you have to be careful what you do to it later.)

--
George Greer  -  Me@Null.net   | Genius may have its limitations, but stupidity
http://www.van.ml.org/~greerga | is not thus handicapped. -- Elbert Hubbard


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