Basic computer course, C programming language, Education, Engineering Course, Engineering Courses, Maths Coaching, online computer coaching, PGDCA course coaching, programming course, school computer coaching, training, Uncategorized, Web Design course

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.

void-pointer-in-c

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.

Coding a data structure such as linked list. Without the use of pointers, this becomes an impossible task with C.

Pointer is used to allocate dynamic memory.

Pointers allow you to refer to the same space in memory from multiple locations. This means that you can update memory in one location and the change can be seen from another location in your program.

To learn more about pointer or any concepts of C Programming Language

Visit us @ http://tccicomputercoaching.com/

Call us @ 9825618292

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s