Dynamic malloc problem

Johnny Favorite (it means "Writhing Tentacle of Death") allen@snakebite.com
Sat Jan 1 23:26:00 GMT 2000


clifford.smith wrote:
> sine I allocate memory with malloc for table in the main() it
> works perfectcly. As soon as I try to allocate this memory in
> a function (void my_funct() ... ) I get a segm. fault.
>
> What can I do. Is there another way to dynamicaly allocate mem ?

The fault is in your code.  There is absolutely no reason why you shouldn't
be able to malloc() in a function other than main().  Look for bugs.




More information about the Gcc-help mailing list