Node.h run error in language c

i have to use fuction node.h for program me.
run error here==> newNode = (struct Node *)malloc(sizeof(struct Node));
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
 
#include<stdio.h>
#include<stdLib.h>
//structure Link List
struct node{
int item;
struct Node *next;
};
//Function insert new node in Link List
    struct Node *insertNode (int newitem,struct Node *nextNode){
    struct Node *newNode;
    newNode = (struct Node *)malloc(sizeof(struct Node));  <<<<============here
    newNode->item = newitem;
    newNode->next = nextNode;
    return(newNode);
}


and  i use for program this.


#include <stdio.h>
#include <stdlib.h>
#include <node.h>
#define true 1
#define false 0
typedef int boolean;
struct Node *newNode;
struct Node * head;
struct Node * curr;
struct Node * prev;
//add node in like list
void add(int newItem) {
        if (head == NULL) {
        newNode = insertNode(newItem,NULL);
    } else {
        newNode = insertNode(newItem,head);
    }
    head = newNode;
}
//search node in link list
boolean searchItem(int item) {
    curr = head;
    prev = NULL;
    boolean status = false;
    while (curr->item == item) {
        if (curr->item == item) {
        status = true;
        break;
    } else {
        prev = curr;
        curr = curr->next;
    }
 }
    if (status) {
      return trun;
    } else {
    reture false;
    }
}
//delete node in link list
int deleteNode(int item) {
    if (searchItem(item)) {
        if(prev ==NULL) {
            head = curr->next;
    } else {
        prev->next = curr->next;
    }
    } else { printf("Not found item.\n");}
}
//insert node in link list
int insert(int iteminsert,int newitem) {
    newNode = insertNode(newItem,NULL);
    if (searchItem(iteminsert)) {
        if (prev == NULL) {
            newNode->next = curr;
            head = newNode;
        } else {
            newNode->next = curr;
            prev->next = newNode;
    }
 } else {
        if (head == NULL) {
            newNode->next = curr;
            head = newNode;
        } else if (curr == NULL) {
            prev->next = newNode;
    }
}
}
//show data node in link list
int showdata () {
    curr = head;
    while (curr != NULL) {
        printf ("%d",curr->item);
        curr = curr->next;
    }
    printf ("\n");
}
int main () {
    add (9);
    printf ("add 9 : ");
    showdata();
    add (10);
    printf("add 10 : ");
    showdata();
    add (11);
    printf ("add 11 : ");
    showdata ();
    add (12);
    printf ("add 12 : ");
    showdata()
    deleteNode (10);
    printf ("delete 10 : ");
    showdata ();
    deleteNode (12);
    printf ("delete 12 : ");
    showdata();
    insert (11,15);
    printf ("insert 15 before 11 : ");
    showdata();
    insert(11,17);
    printf ("insert 17 before 11 : ");
    showdata();
    insert (18,19);
    printf ("insert 19 at last Link List");
    showdata();
    scanf("%d");
}   

  
Last edited on
The first thing you need to realize is that C is case sensitive so things like "#include<stdLib.h>" and "#include<stdlib.h>" and "Node" and "node" are not the same.
i do program already. but it Inconclusive. it' to error position

newNode = (struct Node *)malloc(sizeof(struct Node));
Topic archived. No new replies allowed.