Re: [CODE] Crashing

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

On Fri, 27 Mar 1998, Fili wrote:

>peter hartman wrote:
>>   char buf[MAX_STRING_LENGTH];
>            ^^^^^^^^^^^^^^^^^^^^
>Change to char *buf;
>That should add some length to the string.

No, that'll cause a crash because you haven't allocated any memory for the
'char *buf;'.  You'd have to do:

char *buf = (char *)malloc(the_size_here);

But by then there is little point to do that instead of using the stack
because you may forget to free() the char *.

George Greer  -   | Genius may have its limitations, but stupidity | is not thus handicapped. -- Elbert Hubbard

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

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