data strucure
- // data structure ---- linked list-2
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- using namespace std;
- int main()
- {
- typedef struct list_node* list_pointer; // create another name for list_node called list_pointer
- typedef struct list_node
- {
- int data ;
- list_pointer link;
- } ListNode;
- //Variable
- list_pointer first, second;
- first = (list_pointer) malloc(sizeof(ListNode));
- second = (list_pointer) malloc(sizeof(ListNode));
- second -> link = NULL;
- second -> data = 20;
- first -> data = 10;
- first ->link = second;
- printf("%d",first-> data);
- printf("%3d",second->data);
- free(first);
- free(second);
- }
留言
張貼留言