|
-
Jan 17th, 2006, 10:15 AM
#1
Thread Starter
Hyperactive Member
Passing function arguments by refrence
In C.
When you declare your function prototypes and you want to pass the argument values by refrence, do you have to use the indirection operator in the argument definition list? I haven't really done work with pointers for a while and I can't remember...
Also I wanted to know that since the memory address of an array just points to the first address in a contigous segment of addresses for each element, why is it that you can't access the memory addresses for the array elements other than the first one? And if you can, how can you do it?
Last edited by GamerMax5; Jan 17th, 2006 at 06:16 PM.
-
Jan 17th, 2006, 10:45 AM
#2
Addicted Member
Re: Passing function arguments by refrence
There's no pass by reference in C
In C there's only pass by Value
In C++ there's only pass by value and pass by reference
#Appreciate others by rating good posts !!
#The Software Peter Principle is in operation when unwise developers "improve" and "generalize" the software until they themselves can no longer understand it, then the project slowly dies.
#People who are still ignorant of their ignorance are dangerous.
-
Jan 17th, 2006, 11:36 AM
#3
Re: Passing function arguments by refrence
The only way to pass by reference in C is to use pointers.
The address of the second element of an array can be written a + 1 or &a[1]
-
Jan 17th, 2006, 05:21 PM
#4
Thread Starter
Hyperactive Member
Re: Passing function arguments by refrence
Thanks twanvl. I didn't think about that. lol
So then using your example, every array element past the first one's can be accessed by incrementing the current element. Thx.
BTW... *slaps sunnypalsingh* Just kidding.
Last edited by GamerMax5; Jan 17th, 2006 at 06:20 PM.
-
Jan 18th, 2006, 12:14 AM
#5
Addicted Member
Re: Passing function arguments by refrence
 Originally Posted by GamerMax5
BTW... *slaps sunnypalsingh*  Just kidding.
May I know what made you say so
#Appreciate others by rating good posts !!
#The Software Peter Principle is in operation when unwise developers "improve" and "generalize" the software until they themselves can no longer understand it, then the project slowly dies.
#People who are still ignorant of their ignorance are dangerous.
-
Jan 18th, 2006, 12:36 AM
#6
Re: Passing function arguments by refrence
Feel free to PM eachother if you have an issue, but we don't need it in this forum.
Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|