Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- struct Node
- {
- int data;
- struct Node *link;
- };
- int main()
- {
- struct Node nodes[50];
- struct Node *head = &nodes[0];
- struct Node *tail = head;
- int num_nodes_used = 1;
- int number = 0;
- do{
- printf("node # %d > ", num_nodes_used);
- fflush(stdout);
- scanf("%d", &number);
- if(number){
- tail->data = number;
- tail->link = &nodes[num_nodes_used++];
- printf("Tail data is %d\nTail address is%x\n", tail->data, tail);
- tail = tail->link;
- }
- tail->link = NULL;
- }while (number != 0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment