Ray Of Hope

A risky affair

Does, passing the address as a variable and then using it it to decipher the value is a risky affair ? and should it not be preferred ?

These are the questions which I am thinking and trying to find out answers for..

Just giving you a simple example to explain what I meant..

void print(int val)


printf(“%d”, * (int *)(val) );


void main()


int a;



Here the address is being passed to print function which is receiving it as an integer variable instead of as a pointer (print ( int *ptr)) . Anyhow will it make any difference.. Receiving the variable as a pointer or as an integer, as the ultimate goal is to extract the value out of the address which is possible using both of the means..

Just faced this delimma while working on a problem so wanted to share it with you all.

Anshul Makkar, anshul_makkar@justkernel.com

Originally Posted On: 2010-12-20 03:58:37

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.