Pointers

Before you start: To learn how to compile a c programme click here or click here


Pointers are the 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 a 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

code of pointers
programming code for pointers

  1.  We should include standard input/output header file (stdio.h).
  2. must define a main function in program.
  3. In this program we define two integer type variable ,one is a(simple holds a integer value) and another is *b (it is a integer pointer variable which  can holds the address of any variable).
  4. Assign a value in a.
  5. Assign the address of a in b.(as we know b is a variable of pointer type).
  6. Print the address of a by &a and b (by both methods we can find the address )
  7. Print the value of a by simple printf(“%d”,a) method and by printf(“%d”,*b) method(pointer’s method).

output:

output snap
Output of above proram

 


As we can see the output of previous program
by both the method address is same and also by both methods value is also same.
note that printing the value of  *(&a) give same result as printing the value of a.

To learn more in C click here