The value of a pointer might be determined by printing.
*ptr[0]
Since this is the proper syntax. Also if you print the address of prt[0] using
&ptr[0]
it will give the same address as of the var variable because it will automatically assign the 0'th index in the array of integer with the var.
To check results, you might use the modified code below.
#include <stdio.h>
int main()
{
int var=100;
int(*ptr)[5];
ptr=&var;
printf("Value of var is : %d\n",var); // it will print 100.
printf("Address of var : %u\n",&var); // it will print an address.
printf("Value inside ptr after ptr=&var : %u\n",*ptr[0]); // it will print 100.
printf("Value of ptr[0] is : %d\n", *ptr[0]); // it will print 100.
printf("Address of ptr[0] is : %u\n",&ptr[0]); // it will print the address same as var.
printf("Value of ptr[1] is : %d\n",*ptr[1]); // it will print garbage value.
printf("Address of ptr[1] is : %u\n",&ptr[1]); // Address.
printf("Value of ptr[2] is : %d\n",*ptr[2]); // garbage value
printf("Address of ptr[2] is : %u\n",&ptr[2]); // Address.
return 0;
}
Here's my output.
Value of var is : 100
Address of var : 1386442756
Value inside ptr after ptr=&var : 100
Value of ptr[0] is : 100
Address of ptr[0] is : 1386442756
Value of ptr[1] is : -87802171
Address of ptr[1] is : 1386442776
Value of ptr[2] is : 32767
Address of ptr[2] is : 1386442796