delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/07/14/19:15:20

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: Martin Ambuhl <mambuhl AT earthlink DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: pointers to structs
Date: Wed, 14 Jul 2004 19:08:48 -0400
Lines: 11
Message-ID: <2llso8Fe5t0pU3@uni-berlin.de>
References: <ACAAE6BD7520AB4CB2744D1D1BAD3A2BA1446E AT jupiter DOT insideai DOT com>
Mime-Version: 1.0
X-Trace: news.uni-berlin.de dPzZi8BR1l2kGgHFfuz6yQqzZNjQ9WtumiS1U8hpDznklVo/pj
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040616
X-Accept-Language: en-us, en, de, fr, ru, zh, ja
In-Reply-To: <ACAAE6BD7520AB4CB2744D1D1BAD3A2BA1446E@jupiter.insideai.com>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

John Bond wrote:

> You need to allocate the list memory first like so:
> 
> list = (struct data_list *) malloc(sizeof(struct data_list));

Better:
   list = malloc(sizeof *list);

Remember to #include <stdlib.h> and to check the list after this call to 
make sure that malloc succeeded.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019