Declare and initialize an int variable - C Pointer

C examples for Pointer:Pointer Variable

Description

Declare and initialize an int variable

Demo Code

#include <stdio.h>


int main( void )
{
    int var = 1;//w w w . j  a v a 2s. c o  m
    int *ptr;

    ptr = &var;

    printf("\nDirect access, var = %d", var);
    printf("\nIndirect access, var = %d", *ptr);

    printf("\n\nThe address of var = %d", &var);
    printf("\nThe address of var = %d\n", ptr);

    return 0;
}

Related Tutorials