473,771 Members | 2,372 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C : Call by value or reference

Does C follow call by value convention or call by reference?
i see that there is nothing like reference in C standard but it is
referenced.

still, what should be the answer for the above question?

Jul 15 '07 #1
22 4191
In article <11************ **********@g4g2 000hsf.googlegr oups.com>,
Nehil <ne***********@ gmail.comwrote:
>Does C follow call by value convention or call by reference?
i see that there is nothing like reference in C standard but it is
referenced.

still, what should be the answer for the above question?
Are you the same "Nehil" who is undertaking to write
a garbage collector for C (*)? If so, have you ever heard the
advice "Walk before you run?"

(*) And, no doubt, next week, the Mars lander program.

Jul 15 '07 #2
On Jul 15, 6:00 pm, gaze...@xmissio n.xmission.com (Kenny McCormack)
wrote:
In article <1184504183.456 641.240...@g4g2 000hsf.googlegr oups.com>,

Nehil <nehilparas...@ gmail.comwrote:
Does C follow call by value convention or call by reference?
i see that there is nothing like reference in C standard but it is
referenced.
still, what should be the answer for the above question?

Are you the same "Nehil" who is undertaking to write
a garbage collector for C (*)? If so, have you ever heard the
advice "Walk before you run?"

(*) And, no doubt, next week, the Mars lander program.
have u changed your name or r u same as Eric Sosman?
well, what if i want to learn the new concepts of much debate. and by
now the garbage collector is almost done as a low lovel project. and
all the things i've asked are related to this project only somehow.
so if u know the answer plz reply appropriately.

Jul 15 '07 #3
Nehil said:
Does C follow call by value convention or call by reference?
C is a 100% call-by-value language. Function arguments are expressions,
not objects. These expressions are evaluated, and those values are
passed to the function.

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jul 15 '07 #4
Nehil wrote:
Does C follow call by value convention or call by reference?
Call by value.

If one wants the effects provided by call-by-reference, one has to
implement them by hand.

[Note that for /arrays/, it can /look like/ call by reference;
but that isn't anything to do with parameter-passing, it's
to do with the way C arrays decay into pointers.]
i see that there is nothing like reference in C standard but it is
referenced.
Pardon?
still, what should be the answer for the above question?
I don't know what the answer /should/ be; I only know what it /is/.

--
Passed By Name Hedgehog
"Our future looks secure, but it's all out of our hands"
- Magenta, /Man and Machine/

Jul 15 '07 #5
Nehil wrote:
Does C follow call by value convention or call by reference?
i see that there is nothing like reference in C standard but it is
referenced.

still, what should be the answer for the above question?
C only supports call by value. However you can simulate call by
reference using pointers.

Jul 15 '07 #6
On Sun, 15 Jul 2007 13:22:52 +0000, Richard Heathfield wrote:
>C is a 100% call-by-value language. Function arguments are expressions,
not objects. These expressions are evaluated, and those values are
passed to the function.
This statement is not wrong but highly misleading. Esp. it doesn't
cover the distinction between the following:

void foo1 (stuct something sth);
void foo2 (stuct something* ptr);
--
Roland Pibinger
"The best software is simple, elegant, and full of drama" - Grady Booch
Jul 15 '07 #7
santosh <sa*********@gm ail.comwrites:
Nehil wrote:
>Does C follow call by value convention or call by reference?
i see that there is nothing like reference in C standard but it is
referenced.

still, what should be the answer for the above question?

C only supports call by value. However you can simulate call by
reference using pointers.
and arrays...

http://mces.blogspot.com/2005/08/pas...ence-in-c.html
Jul 15 '07 #8
rp*****@yahoo.c om (Roland Pibinger) writes:
On Sun, 15 Jul 2007 13:22:52 +0000, Richard Heathfield wrote:
>>C is a 100% call-by-value language. Function arguments are expressions,
not objects. These expressions are evaluated, and those values are
passed to the function.

This statement is not wrong but highly misleading. Esp. it doesn't
cover the distinction between the following:

void foo1 (stuct something sth);
void foo2 (stuct something* ptr);
It's all "words". I suspect the OP was looking for pointers - which also
makes me wonder if he is a troll. Since how can he implement a garbage
collector and not either (a) know the answer or (b) know how to google
up the answer.
Jul 15 '07 #9
Roland Pibinger wrote:
On Sun, 15 Jul 2007 13:22:52 +0000, Richard Heathfield wrote:
>>C is a 100% call-by-value language. Function arguments are expressions,
not objects. These expressions are evaluated, and those values are
passed to the function.

This statement is not wrong but highly misleading. Esp. it doesn't
cover the distinction between the following:

void foo1 (stuct something sth);
void foo2 (stuct something* ptr);
Two functions, distinguished by argument types only. So what?
Structs are passed by value, and pointers are passed by value.
What distinction are you referring to?

--
Multiple Valued Hedgehog
Nit-picking is best done among friends.

Jul 15 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1476
by: enjoying the view | last post by:
I am working on a school project, trying to build a simple RPC stub generator. The idea is that the generator takes a normal python file with functions defined in it and produces a client and server stub. The client stub has the same functions defined, but they just connect to the server and ask it to call the desired functions. The server stub is a server listening for incoming requests and dispatching them to the appropriate functions...
3
3208
by: jamihuq | last post by:
Hello all, I have a question. Does the concept of call by reference exist in C like it does in C++? And if so, can someone give me an example. Thanks Jami
1
2456
nabh4u
by: nabh4u | last post by:
Hi, I have a problem referencing to Vectors using pointers i.e. I am not able to use "call by reference" on vector variables. I have a "read()" function in "x.cpp" and "main()" in "y.cpp". I have 3 vector variables in Main(). I want the read function to read the values into the vector using the address I send of the vectors.. Sample code: //x.cpp void read(vector <int> a,vector <int> b,vector < vector <int> > c)
10
16675
by: ravi | last post by:
Hi, i am a c++ programmer, now i want to learn programming in c also. so can anybody explain me the difference b/w call by reference and call by pointer (with example if possible).
10
2294
by: psbasha | last post by:
Hi, Is Python supports Call by reference and Call by address in function or methods,without using C/C++ modules?. Thanks in advacne PSB
3
4314
Digital Don
by: Digital Don | last post by:
I have a problem sending the Vectors as Referencial parameters..i.e. I am having a struct vector struct board { int r; int c; };
7
3523
by: Saeed Amrollahi | last post by:
Dear All Hi I have learned when an object is big, I should pass the object using a reference or pointer to it rather than calling by value. In the following code, I don't gain cosiderable performance with call- by-reference vs. call-by-value. Indeed, the perforamnce is absolutely unconsiderable: #include <vector>
15
1735
by: coolguyaroundyou | last post by:
Does C have Call-By-Reference for a function?? I think it doesn't. Am I right?
0
9619
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10260
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6712
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.