Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct list {
- int value;
- struct list* next;
- } list_s;
- static int g_size=sizeof(list_s);
- void printRe(list_s *node) {
- if (node = NULL)
- return;
- printRe(node->next); // this is where error happens
- printf("%d", node->value);
- }
- int main() {
- list_s *head;
- head = (list_s*)malloc(g_size);
- int n;
- scanf("%d",&n);
- int i = 0;
- int x;
- scanf("%d", &x);
- head->value = x;
- head->next = NULL;
- list_s *current;
- current = head;
- for (i; i < n - 1; ++i) {
- current->next = (list_s*)malloc(g_size);
- current = current->next;
- scanf("%d", &x);
- current->value = x;
- current->next = NULL;
- };
- printRe(head);
- return 0;
- }
Add Comment
Please, Sign In to add comment