Re: kinda dumb question...

From: Angus Mezick (amezick@edgil.com)
Date: 02/02/00


Apologize to Rohan who gets this twice. (drats)

NO NO NO NO NO NO NO!!!!!!!
Doing sprintf(buf,"%d%s",num,buf); is EXTREMELY BAD! and EXTREMELY
non-portable.  Different implementations of sprintf handle the
target buffer different ways.  Some of them clear it before they
build the string, thus you would be copying and empty buf into buf.

use sprintf(buf+strlen(buf),"[%d]\r\n");


Point 2, you want \r\n, not \n\r. Look back in the changes log for reasons
behind this.

--Angus
Rohan Wallace wrote:
>
> Try this:
>
> >     sprintf(buf2," [%d]\n\r", num);
> >                 strcat(buf, buf2);
> >             }
> >
>
> Replace the above with:
>
>       sprintf (buf, "[%d] %s\n\r", num, buf);
>               }
>
> Rohan Wallace                      SE Net
> System Programmer                  222 Grote Street
> SE Network Access                  Adelaide SA 5000
--
Angus Mezick                                    Edgil Assoc.
PH:978-251-9932                                 15 Tyngsboro Rd
FX:978-251-9970                                 N. Chelmsford MA 01863-1344
amezick@edgil.com

Photons have neither morals nor visas.


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 04/10/01 PDT