![]() |
|
#1
|
|||
|
|||
passing pointers to structure to fnshi,
this is my first time posting... trying to get this to work for a project im working on at work... it all compiles... im compiling using the gcc cmd on a UNIX system (i dont know what version).. basically within MAIN it all works very nicely.. when i pass the pointer by reference to the fn i cant access what i need to.. any help is greatly appreciated.. ::: CPP / C++ / C Code:
Last edited by JdS : 04-Jun-2004 at 18:41.
Reason: Please enclose c code in [c] & [/c] for syntax highlighting
|
|||
|
#2
|
||||
|
||||
|
__________________
-Aaron |
|
#3
|
||||
|
||||
|
Hi 00rish. Welcome to GIDForums. I haven't compiled the program or anything, so I don't know if this will solve your problem.
Why are you dereferencing your struct when passing here: CPP / C++ / C Code:
Instead of passing &depth_array, just pass depth_array. I don't know if that will solve your problem for sure. |
|
#4
|
||||
|
||||
|
Dsmith is right. One thing you should know about arrays is that they're always passed by reference (aka by pointer). When you pass the name of an array to a function, you're actually passing its base address, because it would be impractical and inefficient to make a copy of the array, especially since the compiler may not know how big it is. So, you do not need to pass it by reference or by pointer, because it's already done for you by the compiler.
__________________
-Aaron |
|
#5
|
|||
|
|||
thanks to allhey guys,
you are correct.. that was my problem!.. So frustrating as I was stuck on this for a day and a half... I thought I had tried getting rid of the &, but it must have been before when I had some other errors in my code! Thanks again! ~Rishi |
Recent GIDBlog
Once again, no time for hobbies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [CONTEST?]Data Structure Test | dsmith | C Programming Language | 2 | 06-Jun-2004 16:13 |
| strlen error (need help with pointers) | mitosis | C Programming Language | 1 | 24-Apr-2004 07:50 |
| Help with C++ pointers | Mjkramer21 | C++ Forum | 23 | 18-Apr-2004 08:53 |
| Passing Pointers To Pointers in Functions | elumira | C Programming Language | 8 | 05-Mar-2004 22:23 |
| pointers and arrays | jack | C Programming Language | 4 | 15-Jan-2004 13:27 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The