Jawad Khutaba Jawad Khutaba -4 years ago 62
C Question

completing this code (c) if you can

typedef struct node
int data;
int help;
struct node* next;
void Nodes_maker(int nums,Node *currentnode);
int main()
int count2;
Node* root;
Node* currentnode;
printf("How many numbers do you want? ");
return 0;
void Nodes_maker(int nums,Node *currentnode)
int i;

would someone help me complete this code?
i have the Node struct that contains 'data','help','next'.
i want to scanf a number from the user about how many numbers he wants (how many 'data' fields he wants) and making those Node structs (The 'next' field contains a pointer to another new 'data' field in another Node struct.

Answer Source

Change this:


to this:

Nodes_maker(count2, currentnode);

and the error will go away. That is because the prototype of the function is Nodes_maker(int nums,Node *currentnode) and you have Node* currentnode;.

However, you need to work on your logic. I mean you dynamically allocate memory, but you don't return the pointer (your function returns void). Good luck!

PS: Do I cast the result of malloc? No.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download