C Pointers : Use of Pointers in C with simple Steps

C Pointers  are the most difficult feature of C for beginners .Other languages have Pointers  but only few use them as frequently as C does.But Beginners should have to remember that C’s clever use of  Pointers make C an excellent language .

Most of the Beginners feel difficulty in the Pointers terminology rather then the actual concepts of pointers.

Actually when a C programmer says that this variable is a pointer, what does it means ??
It seems hard to see how a variable can “point” to something/or in  a direction.

TO examine let us make a program

Use Pointers in C
programming code for pointers
  • In the first line, we include standard input/output header file (stdio.h).
  • must define a main function in program.
  • In this program we define two integer type variable ,one is a(simple holds an integer value) and another is *b (it is a integer pointer variable which can hold the address of any variable).
  • Assign a value in a.
  • Assign the address of a in b.(as we know b is a variable of pointer type).
  • Print the address of a by &a and b (by both methods we can find the address )
  • Print the value of a by simple printf(“%d”,a) method and by printf(“%d”,*b) method(pointer’s method).

output:
Use Pointers in C using Kali
Output of above program

As we can see the output of previous program by both the method,

 

By both of the methods, address and value is same.
note that printing the value of  *(&a) give same result as printing the value of a.

Have something to add on Use C pointers  ? Please add in comments.

Follow us on Facebook, Google Plus and Twitter to get more Tech News and reviews.

Previous                                                                                 Next

Comments are closed.