Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- struct node
- {
- int data;
- struct node *next;
- }*stnode;
- void main()
- {
- int i, n;
- int item;
- struct node *new_node, *p, *head;
- printf("Enter number of Nodes :");
- scanf_s("%d ", &n);
- printf("Enter Value : \n");
- scanf_s("%d", &item);
- new_node = (struct node *)malloc(sizeof(new_node)); // הקצאה לצומת חדשה
- new_node->data = item; // Value = Inputed Item
- new_node->next = NULL; // Next = NULL
- head = new_node; // First Node = Head
- p = new_node; // Pointer to the first node that inputed.
- for (i = 1; i < n; i++) // Loop to Scan Node input N times.
- {
- printf("Enter Next Node : \n");
- scanf_s("%d ", &item);
- new_node = (struct node *)malloc(sizeof(new_node)); // הקצאה לצומת חדשה
- new_node->data = item; // Value = Inputed Item
- new_node->next = NULL; // Next = NULL
- p-> next = new_node; // Linking Node A to Node B to ........
- p = p-> next; // P Moves to B Node ... Waiting for Another Iteration......
- }
- p->next = head; // Points to the First Node --- > This Statement make it Circular Linked List.
- }
- //void deleteListInstance(node *list, list_item x)
- //{
- /////// Delete from the list.
- //}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement