Re: Which is the best way...

From: Tony Robbins (
Date: 08/16/99

----- Original Message -----
From: Chuck Carson <>
To: <>
Sent: Monday, August 16, 1999 2:52 PM
Subject:  Which is the best way...

> When you are adding to a buffer before sending it to the
> character, which is the more suitable method?
> 1)
> sprintf (buf + strlen(buf), "blah.....");
> or 2)
> sprintf(buf, "%sblah......", buf);
> Or do these two end up the same at the binary level
> anyway?

I couldn't tell you about that, but there's a reason why CircleMUD changed
all the:
sprintf(buf, "%s...", buf);
sprintf(buf + strlen(buf), "...");

The main reason, as I recall, is that a compiler for Windows, Borland I
believe, clears out a buffer before printing into it.

So sprintf(buf, "%s...", buf); ends up just being "...".

I personally use sprintf(buf + strlen(buf), "..."); for no other real reason
than personal preference.  I don't use Borland or anything, but it's nice to
know your code is consistent.


     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  |

This archive was generated by hypermail 2b30 : 12/15/00 PST