GPicasso
asked on
What does this mean in C?
return L->Next == NULL;
Most specifically what does
I expect this is extremely basic
Most specifically what does
->
doI expect this is extremely basic
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
As for_yan said, L is a pointer to a structure. You would find out which structure by finding the declaration for L. In this case, I would guess that this function is processing a linked list (or similar). Here's an example (untested).
typedef Node
{
Node *link;
char item [ 50 ];
} Node;
int isLastElement ( struct Node *L )
{
return L->next == NULL;
}
main()
{
...
if ( isLastElement ( &Node ) )
printf ( "We are at the last element\n" );
....
}
farzanj just said what I was going to put in my next post. He is correct as well.
ASKER
Ok so like if I have a struct named L
->L is like *L
meaning it returns the address of L... correct?
->L is like *L
meaning it returns the address of L... correct?
Next should be another field of the structure that give the address of the next estructure data, this type of definition is used to create a linked list. *L = address of the current node of the structure
L->next = address of the next node of the structure
check the following
http://gd.tuwien.ac.at/languages/c/programming-bbrown/c_086.htm
L->next = address of the next node of the structure
check the following
http://gd.tuwien.ac.at/languages/c/programming-bbrown/c_086.htm
Evilrix, I don't know where the repeat comes from. If it's me, it's one of my tutoring methods that's been successful in getting to the "Oh....I see" moment. It doesn't work for everyone. It works for some students.
Picasso, L-> is like (*L). Please look at farzanj's post again. Then look at my first post with code. Replace line 9 with
Mostly L-> is easier to type and read.
sonagu's reference is very good if you need/want help understanding Linked Lists.
Picasso, L-> is like (*L). Please look at farzanj's post again. Then look at my first post with code. Replace line 9 with
return (*L).next == NULL;
Mostly L-> is easier to type and read.
sonagu's reference is very good if you need/want help understanding Linked Lists.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Evilrix, my apology if I repeated/re-worded the previous post, although I never though it was against EE policy and if it is please quote it.
In C, a variable (x) of a struct (A) is accessed by A.x
Now if you have a pointer (B) to the struct, you have to use (*B).x or B->x