Mail Archives: djgpp/2004/07/15/09:16:17
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 -