#include <stdio.h>
#include <stdlib.h>
struct Node{
int data;
struct Node* link;
};
struct Node* A;
int main(){
struct Node* temp = (struct Node*)malloc(sizeof(Node));
temp->data = 2;
temp->link = NULL;
A = temp; // in this line i have doubt
return 0;
}
The doubt is that: A and temp both are pointer to node. A = temp can have two meanings:
- We are copying the address of temp in A, hence A will point to the same address.(means both of them are same identities/variables)
- We are copying the elements of temp and assigning it to elements of A.(means both of them are separate identities/variables). We generally do this in structures.
So please help me to understand it.