I created a very simple program of linked lists in C.
#include<stdio.h>
#include<stdlib.h>
int main(){
struct Int{
int num;
struct Int *ptr;
};
typedef struct Int NODE;
NODE *start;
start = (NODE *) malloc(sizeof(NODE));
(*start).num = 100;
(*start).ptr = (NODE *) malloc(sizeof(NODE));
(*start).(*ptr).num = 123;
(*start).(*ptr).ptr = NULL;
}
When I replace the last two lines as :-
start -> ptr -> num = 123;
start -> ptr -> ptr = NULL;
The error solved.
The question is that why I can't use (* start).
instead of start ->
.According to this answer What does this mean "->"?
both of them are same.