Originally Posted by
laserlight
Just print the pointer whose value was returned by malloc:
Code:
printf(" address : %p \n", (void*)st);
I have doubt Am I printing correct value of N
Code:
#include <stdio.h>
#include <stdlib.h>
struct student
{
int roll_no;
struct student *N;
};
int main()
{
struct student *st = (struct student*) malloc(4 * sizeof(struct student));
struct student *s1 = (struct student*) malloc(4 * sizeof(struct student));
printf(" address : %p \n", (void*)st);
st->roll_no = 10;
st -> N = s1;
printf(" value : %d \n", (st )-> roll_no);
printf(" N : %p \n", (st )-> N);
return 0;
}
address : 00B10DD8
value : 10
N : 00B10E00