In this declaration:
int *var_name = &a;
there is declared the variable var_name of the pointer type int *
and this variable (pointer) is initialized by the address of the variable a
.
It seems you mixing the symbol *
in declarations and in expressions.
In declarations it denotes a pointer. In expressions it denotes the dereference operator.
Consider the following demonstration program:
#include <stdio.h>
int main( void )
{
int a = 5;
int *var_name = &a;
printf( "The address stored in var_name is %p\n", ( void * )var_name );
printf( "The address of the variable a is %p\n", ( void * )&a );
printf( "The value of the object pointed to by var_name is %d\n", *var_name );
printf( "The value stored in the variable a is %d\n", a );
}
Its output might look like
The address stored in var_name is 00EFFAC0
The address of the variable a is 00EFFAC0
The value of the object pointed to by var_name is 5
The value stored in the variable a is 5
That is in this line:
int *var_name = &a;
*var_name
means a declarator of a pointer type.
In this call:
printf( "The value of the object pointed to by var_name is %d\n", *var_name );
*var_name
means an expression with the dereference operator *
.