Pointer Address and Value

For pointers in C language, & and * operators are very important. To use a pointer, the understanding of both operators is a must. The meaning of both is as explained below.

Meaning of & operator

‘&’ operator is called address operator. We can spell ‘&’ as “address of” whenever we are using it. This operator is used when we want to take or find the address of any variable or value. Let us understand it by some examples. 

Ex. b=&a is called the address of a.
Which means ‘b’ gives the address, where ‘a’ variable is stored. In short ‘b’ is the location of variable ‘a’ in memory.

Ex. c= &(119) is called address of value 119.
Means ‘c’ gives a location in memory where value 119 is stored.

Meaning of * operator

‘*’ operator is called an indirection operator . We can spell ‘*’ as “value at” whenever we are using it. So this operator is used when we want to get or find value from any location. Let us understand it by some examples. 

Ex. b= *a is called value at location a.
Which means ‘b’ gives the value at location ‘a’. In short ‘b’ is valued at location ‘a’ in memory.

Ex. c = *(119) is called value at location 119.
Means ‘c’ gives the value at location 119 in memory.

Combination of * and & operators.

Combination of * and & cancel each other. Let us understand it by some examples.

Ex.  a = *(&b) 
That means value at address of b. Which is the same as ‘b’.

Ex. c = *(&119)
It says value at address of 119, which is 119.

Learning from this blog:

  1. Use of * operator.
  2. Use of & operator.
  3. How to spell * and & operator.
  4. How important both are in the C language.
  5. What is the result of combining & and * operators?
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments