[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Strange behaviour with free()
From: |
Mike Castle |
Subject: |
Re: Strange behaviour with free() |
Date: |
Mon, 3 Sep 2001 17:22:29 -0700 |
User-agent: |
Mutt/1.3.18i |
On Mon, Sep 03, 2001 at 04:40:55PM +0530, Vikaas BV wrote:
>
> #include <stdio.h>
>
> main() {
> char * x;
> char * y;
> char * z;
>
> x = (char *) malloc(sizeof(char) * 100);
At this point, we can already tell your program is broken. You should
not have to cast malloc() to char* here. It seems to indicate a lack
of understanding of the fundamentals of the C programming language (in this
particular case, that you need to include <stdlib.h>).
I suggest getting a good book on C programming and read the C Programming
FAQ at http://www.eskimo.com/~scs/C-faq/top.html.
If you are having problems getting to this point correctly, the rest of
your code is probably suspect.
mrc
--
Mike Castle address@hidden www.netcom.com/~dalgoda/
We are all of us living in the shadow of Manhattan. -- Watchmen
fatal ("You are in a maze of twisty compiler features, all different"); -- gcc