Advertisement
Aminpro

[ECP 1026]Linked list Pre-Code(For Memorization)

Feb 3rd, 2013
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.82 KB | None | 0 0
  1. https://www.facebook.com/AminproPastebin
  2.  
  3. //1. Creating the element of the list
  4.  
  5. struct name{
  6.     //elements
  7.     struct name *next;
  8. }
  9.  
  10. //2. Create the insert functions
  11. Struct name *insertnode(variables){
  12.     struct name *temp;
  13.  
  14.     temp=(struct name *)malloc(sizeof(struct name));
  15.     temp -> element = variable;
  16.     temp -> next = NULL;
  17.     return temp;
  18. }
  19.  
  20. //3. Using it in main function
  21.  
  22. struct name *head=NULL;
  23. struct name *curr=NULL;
  24.  
  25. head = curr = insertnode(//Set all element to NULL for head);
  26.  
  27. //Inserting the veriables into elements of single node.
  28. curr ->next =  insertnode(variables);
  29. curr = curr ->next; // point the curr to the one you just created.
  30.  
  31. //4. rewinding the head
  32. curr = head -> next;
  33.  
  34. //5. reading the nodes(print)
  35. while(curr){
  36. printf(your elements here of curr);
  37. curr = curr -> next;
  38. }
  39.  
  40. //FIN!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement