What is use of pointer in C? tccicomputercoaching.com

Page 1

What is use of pointer in C? tccicomputercoaching.com What is pointer? Pointer is a variable used to store address of another variable in programming language. What is the use of Pointer? The importance of pointers comes with the use of functions. For an example think you code a function to add two values and assign it to the first value. I'll show you how to do it with and without pointers.

Without pointer int adder(int a, int b){ return a+b; } void main() { int c = 5; int d = 6; c = adder(a,b); } So here no use of pointers and this method of using functions is called as call by value. Here value of c 5 and value of d 6 is passed to function adder as a and b and return the value. So, you should use pointers any place where you need to obtain and pass around the address to a specific spot in memory.


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.
What is use of pointer in C? tccicomputercoaching.com by Rosario Riley - Issuu