Re: Writing over the end of a string

From: Mark A. Heilpern (heilpern@mindspring.com)
Date: 09/09/99


At 12:30 PM 9/9/99 -0700, you wrote:
>Is there any danger to doing this:
>
>
>sprintf(buf, mob->long_desc   (which contains a newline code)
>
>Then do this,
>
>sprintf(buf + (strlen(buf) - 1), " more text\n");
>
>Effectively writing over the first new line, adding more
>text and then adding a new 'newline'.

strlen() does not count to the first carriage return, it counts to the
string termination (null character). Otherwise, what you have is fine.


     +------------------------------------------------------------+
     | 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 : 12/15/00 PST