I have a question about the node pointer which i got from website.
void main()
{
node *front;
node *rear;
void qinsert(&front, &rear);
}
void qinsert(node **front1,node **rear1)
{
node *newnode; /* New node to be inserted */
newnode=(node*)malloc(sizeof(node));
newnode->next=NULL;
printf("\nEnter the character to push\n");
fflush(stdin);
scanf("%c",&(newnode->data));
if(*front1==NULL && *rear1==NULL)
{
*front1=newnode;
*rear1=newnode;
}
else
{
(*rear1)->next=newnode;
*rear1=newnode;
}
}
I know that address of front and rear is passed to qinsert function. In the qinsert function we create node *newnode and newnode is a pointer to the block of memory after malloc is initialized. What is the value of *front1 and *rear1 in the if and else condition?
Many thanks
void main()
{
node *front;
node *rear;
void qinsert(&front, &rear);
}
void qinsert(node **front1,node **rear1)
{
node *newnode; /* New node to be inserted */
newnode=(node*)malloc(sizeof(node));
newnode->next=NULL;
printf("\nEnter the character to push\n");
fflush(stdin);
scanf("%c",&(newnode->data));
if(*front1==NULL && *rear1==NULL)
{
*front1=newnode;
*rear1=newnode;
}
else
{
(*rear1)->next=newnode;
*rear1=newnode;
}
}
I know that address of front and rear is passed to qinsert function. In the qinsert function we create node *newnode and newnode is a pointer to the block of memory after malloc is initialized. What is the value of *front1 and *rear1 in the if and else condition?
Many thanks