Using Pointer

Monday, October 19, 2009

This will show You about simple using pointer in C.

#include<stdio.h>

int main(void){
    int y, x = 87;
    int *px;

    px = &x;
    y = *px;

    printf("Giving x = 87 (integer)\n");
    printf("px = &x;\n");
    printf("y = *px;\n\n");
    printf("Address of x = %p\n", &x);
    printf("Content of px = %p\n", px);
    printf("Content of x = %d\n", x);
    printf("Value that being pointed by px = %d\n", *px);
    printf("Value of y = %d\n", y);

    return 0;
}


And this is the result:


0 comments:

Post a Comment

 
 
Copyright © Welcome