delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/07/15/09:16:17

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 <william_peter_oconnell AT yahoo DOT com>
Subject: Re: pointers to structs
To: djgpp AT delorie DOT com
In-Reply-To: <1089842517.34974@proxy2.srv.ualberta.ca>
MIME-Version: 1.0
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,

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 <jdhanley AT telusplanet DOT net> 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 

- Raw text -


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