X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: Martin Ambuhl Newsgroups: comp.os.msdos.djgpp Subject: Re: pointers to structs Date: Wed, 14 Jul 2004 19:07:15 -0400 Lines: 32 Message-ID: <2llslbFe5t0pU2@uni-berlin.de> References: <1089842517 DOT 34974 AT proxy2 DOT srv DOT ualberta DOT ca> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 6FPhL7B7v+Tq+ekUSLoSvAheqp1cz7/oMqpov/nYGuCAYNv96k 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: <1089842517.34974@proxy2.srv.ualberta.ca> 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 Precedence: bulk John Hanley wrote: > I am creating a linked list. I have 2 structs: > > struct data_record > { > struct data_record * next; > }; > > struct data_list > { > struct data_record * head; > struct data_record * tail; > }; > > int main() > { > struct data_list * list; > > list->head = NULL; > list->tail = NULL; > } > > When I compile then run this, I get: "Exiting due to Signal SIGSEGV. Page > Fault at ..." > > Can I not assign NULL to these pointers? There are no pointers, except for 'list', which points nowhere. 'list' needs to have storage allocated for it to point to before there are any list->head or list->tail to use.