Thursday, November 19, 2009

C++ structure linked list sample code?

hello everyone,


is there someone can help me to show a c languange sample code for data structure single linked list (not use class) for student case?

C++ structure linked list sample code?
Here is an example of a link list element.





struct Student {


std::string name;


int id;


Student* next;


};





Using this struct, you can create a linked list as follows.





Student *head;





// add a student to the list. s is inserted to the head.


void add(Student* s) {


s-%26gt;next = head;


head = s;


}

sliders

No comments:

Post a Comment