X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f Message-ID: <20040715124626.86436.qmail@web60701.mail.yahoo.com> Date: Thu, 15 Jul 2004 05:46:26 -0700 (PDT) From: William OConnell Subject: Re: pointers to structs To: djgpp AT delorie DOT com In-Reply-To: <1089842517.34974@proxy2.srv.ualberta.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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, Use a dot instead of an arrow. For example, the following code should work. /* This is the BEGINNING of the code. */ 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; } /* This is the END of the code. I hope this helps. */ --- 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? If I take > the 2 assignments out, > it runs ok. > > Any suggestions as to why I can't initialize my head > and tail to NULL? > > Thanks! > > John > > > > __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! http://promotions.yahoo.com/new_mail