Advertisement
Aminpro

[ECP 1026]Linked List Lecutre Example

Nov 26th, 2012
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. //https://www.facebook.com/AminproPastebin
  2.  
  3. // Linked list Example [26 Nov 2012], Lecutre
  4.  
  5. struct Box{
  6. char colour[20];
  7. float price;
  8.  
  9. struct Box *next;
  10. }
  11.  
  12. void main(){
  13. struct Box *addNode(char colour[], float price);
  14. struct Box *Head =NULL, *Current =NULL; // Create the Head and Current pointers
  15.  
  16. //Creating head Node
  17. Head=Current=addNode("",0); //Head and current is pointing to both node.
  18.  
  19. //Start adding new node.
  20. Current ->next = addNode("Red", 12.5);
  21. Current = Current -> Next;
  22.  
  23. //Continue adding node.
  24. Current -> next = addNode ("Blue", 19.9);
  25. Current = Current -> Next;
  26.  
  27. //Last node.
  28.  
  29. Current -> next = addNode("Green", 45.3);
  30. Current = Current -> Next;
  31.  
  32. //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement