Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

in other programming language like

Status
Not open for further replies.

hughLg

Programmer
Feb 18, 2002
136
MY
in other programming language like Pascal, we can refer the link list like:

top^.next^.data = 123;
top^.next^.next = nil;

but in C, i don't know what's the problem. i just know when i try to compile the following code, error message occurs:

top->next->data = 123;
top->next->next = NULL;

the structure type is defined is like this:

typedef struct {
int data;
struct List *next;
} List;

i have no any problem when i write these:

top->data = 123;
top->next = NULL;

thank you for you attention.

actually, i'm not a actual C/C++ programmer. i call myself as programmer here because i want to be a real programmer. and the programming language i mot like is C/C++. is these 2 languages can produce whatever things? no matter we want or not?
 
The code that's giving you an error looks like it should work as long as
Code:
first->next
is something other than 0. Is the error you get a compiler error, or does the program crash in the middle of execution?

What you're doing in that code is accessing the second item from the top. It's not going to work if there's not a first item from the top yet.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top