fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. typedef struct node{
  6. int val;
  7. struct node * next;
  8. }node;
  9.  
  10. void push(int val, node **head){
  11. node* temp=(node*)malloc(sizeof(node));
  12. if (!temp) printf("Oh no!\n");
  13. node* current=*head;
  14. temp->val=val;
  15. if( (*head) == NULL)
  16. { printf("NULL!\n");}
  17. else
  18. {printf("NOT!\n");}
  19. }
  20.  
  21. int reverse(node * head){
  22. node *previous = NULL;
  23. node *current = head;
  24. node *forward;
  25. while (current != NULL) {
  26. forward = current->next;
  27. current->next = previous;
  28. previous = current;
  29. current = forward;
  30. }
  31. return previous;
  32.  
  33. }
  34.  
  35. void print(node *new_head){
  36.  
  37. node* current2=new_head;
  38. current2=current2->next;
  39. while(current2!=NULL)
  40. {
  41. printf("%d", current2->val);
  42. current2=current2->next;
  43. }
  44.  
  45. }
  46.  
  47. int main()
  48. { node * head= NULL;
  49. int n;
  50. node * new_head;
  51. scanf("%d", &n);
  52. push(n,head);
  53. // scanf("%d", &n);
  54. // push(n,head);
  55. // scanf("%d", &n);
  56. // push(n,head);
  57. // new_head=reverse(head);
  58. // print(new_head);
  59.  
  60. return 0;}
  61.  
Runtime error #stdin #stdout 0s 2424KB
stdin
1
stdout
Standard output is empty