#include<stdio.h>
#include<stdlib.h>
struct test
{
int data;
struct test *next;
};
void main()
{
struct test *head=(struct test *)malloc(sizeof(struct test));
struct test **ref=&head;
head->data=5;
head->next=NULL;
printf("\n %d \n %d",head->data,head->next);
printf("\n %d \n %d",**ref->data,**ref->next);
}
Explanation:
I've tried the above piece of code.
Isn't **ref
same as *head
? If not why?
Also the compiler is throwing an error at the second printf
saying that data
and next
are not part of a structure
or a union
.