top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

Why pointer passing can not be called called by reference in C?

+3 votes

Called by reference is a mechanism where we can bring the changes to a variable done in the called function to calling function which can be done via passing pointers in C. But most of the books are referring that C does not support pass by reference method.

Can someone explain why?

posted Nov 17, 2014 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
C is a procedural language and C++ is an object oriented programming. Procedural language supports the concept of function whereas Object oriented programming supports the concept of methods.

2 Answers

+1 vote

In C everything is pass by the value even if you pass the pointer or double pointer or triple pointer you pass the value and somehow manage the change of value of variable by accessing the location using the pointer value you have received. So in C we call everything is pass by value.

While in C++ you can pass the reference.

answer Dec 9, 2014 by Salil Agrawal
0 votes

Pointer is used to store the address of variable.
So, you are not passing the address of pointer you are just pasing the value of pointer (address of OTHER variable).


int *p,a=10;
p = &a;

So, here you are not passing the address. So, It is not called called by reference.

Now.. If you pass the address of pointer to the function.
Then, In function body (function prototype) you have to catch it through double pointer and now it will be called as call by reference.

    int *p,a=10;
    p = &a;

 void function_name(int **q)
answer Dec 9, 2014 by Chirag Gangdev
Similar Questions
Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.