Need help

This is a discussion on Need help within the C Programming forums, part of the General Programming Boards category; Hi all,
I have a hard time to figure out to code the program assignment below for my C course. ...

int Search(struct stutable *T, int id, struct student **stud)
{
/*Purpose: locate and return a pointer to a student if the
student is found in the stuTable.
return 1 if student is found otherwise return 0 */

}
[\CODE]

What struct student **stud mean? and can anyone help to show me how to code for the Search() function.
Your help would appreciate.
C_dummy

Search(A, id, &B) A is the pointer to a structure. id is the numeric student ID number that you are searching your list in hopes of finding a match. You're passing the address of a pointer for B which is your list. (This has something to do with having access to the last node of the linked list. But the **stud is a double dereference. First dereference gets you access to the address of the pointer, the second gets you access to the pointer itself.)

So when you use the pointer in your function you use it like this:
(*stud)

or a practical example would be...
*stud = (*stud)->stu;
...to step through the list.

so as you search through your linear linked list...
first make a copy of the head pointer so you can get back to the beginning of the list.

Then begin to search through each node of the list by stepping through the list in a while loop. You stop searching when you find the end of the list that you are searching through.

in the loop, test for the equality. if(id==(*stud)->stu.ID)
I think that's the correct useage of -> and . if your compiler complains, then I'm at least close.

hope this gives you enough information to ask more questions or to send me flaming mail.

assuming that Key id is a character string and that Struct B is a struct that looks like this:

struct student{
char* name;
struct* student *NEXT;
};

..and your main() calls the routine like this.
Search(id, listexample); where 'id' is what you are looking for in the linked list and 'listexample' is the linked list
Here is an example of a this search routine involving pointers.