Hi guys , i have a question about din. memory alloc. and i want to ask it with an example.
Code:
/* here is my struct */
struct node
{
int data;
struct node *next;
}
/* here is my simple making node function*/
struct node *makenode(int value)
{
struct node *np;
np=malloc(sizeof(struct node));
np->data=value;
np->next=NULL;
}
What if i did not write the np=malloc(sizeof(struct node)); line, Does the code work properly ? When i need to take a place from memory using with pointer and when i dont need ? Thank you for your answers.