A beginner to Pointers in C often perplexed by different operators & and *
Let’s see what it really is and how simple it is.

& – This operator gives ‘the address of’ a variable
* – This operator gives ‘the value at address’ of a variable

(Note! Note! Note! Not the other way round! By heart it any way!)

Let’s codes speak…


	int myVariable = 25;

	printf("n Address of myVariable = %u", &myVariable);
	printf("n Value of myVariable = %u", myVariable);
	printf("n Value of myVariable = %u", *(&myVariable));


So… the output…


Address of myVariable = 7589
//7589 is the address in memory of the variable myVariable

Value of myVariable = 25
//It simply printed the ‘myVariable’ which contains 25

Value of myVariable = 25
// Please do note that it printed ‘the value at address’ of ‘myVariable’
// Address is passed via &myVariable



Leave a Reply

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




Theme by HermesThemes

Copyright © 2018 CoderzHeaven. All Rights Reserved

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.