#include<stdlib.h> #include<iostream> using namespace std; //what's this? typedef struct node //what's this? { int data; //what's this? node *next; //what's this? } Node; //what's this? Node *createNode(int n) //what's this? { Node *ptr = new Node(); //what's this? ptr->data = n; //what's this? ptr->next = NULL; //what's this? return ptr; //what's this? } Node *appendNode(Node *node, int n) //what's this? { Node *cur = node; //what's this? while(cur) { if(cur->next == NULL) //what's this? { cur->next = createNode(n); //what's this arrows here? return cur->next; //what's this? } cur = cur->next; //what's this? } return cur; //what's this? } void printNodes(Node *head) //what's this? { Node *cur = head; //what's this? while(cur)//What is this I dont get it. { cout<< cur-> data<< " "; //what's this? cur = cur->next; //what's this? } cout << endl; } Node *deleteNode(Node **head) //what's this? { Node *temp = *head; //what's this? *head = temp->next; //what's this? delete temp; //what's this? return *head; //what's this? } Node *insertFront(Node **head, int n) //what's this? { Node *newNode = createNode(n); //what's this? newNode->next = *head; //what's this? *head = newNode; //what's this? return *head; //what's this? } int main() { Node *head = createNode(100); //what's this? appendNode(head, 200); //what's this? appendNode(head, 300); //what's this? printNodes(head); //what's this? head = deleteNode(&head); //what's this? printNodes(head); //what's this? head = insertFront(&head, 100); //what's this? printNodes(head); //what's this? return 0; //what's this? }
C++
*
->
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)