Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- typedef struct node
- {
- int value;
- struct node *next;
- } node_t;
- node_t *head;
- node_t *target;
- void printList(node_t *head)
- {
- node_t *temporary;
- temporary = head;
- while (temporary != NULL && temporary->value != INT_MAX)
- {
- printf("%d - ", temporary->value);
- temporary = temporary->next;
- }
- }
- void insertLinkedList(int temp)
- {
- // printf("hello \n");
- target->value = temp;
- node_t *newNode;
- newNode = (node_t *)malloc(sizeof(node_t));
- target->next = newNode;
- target = newNode;
- // printf("hello 2 ");
- }
- int main()
- {
- node_t *first;
- first = (node_t *)malloc(sizeof(node_t));
- head = first;
- target = first;
- // cout << head->next << endl;
- insertLinkedList(5);
- insertLinkedList(4);
- insertLinkedList(3);
- insertLinkedList(2);
- target->value = INT_MAX;
- target->next = NULL;
- target = NULL;
- printList(head);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement