![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#21 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,223
Rep Power: 5
![]() |
Re: Function returning double pointer ?
If you do that, mbd, the code will not compile with a standard-compliant compiler.
While there are some circumstances where a pointer and an array are equivalent (in the sense of being treated as if they represent the same thing by the compiler), there are some circumstances where they are not. This is one of those circumstances. bar in Narue's code is an array of pointers to char. That cannot be implicitly converted into a pointer to pointer to char -- as, in this context, an array and a pointer are not considered the same thing by the compiler (they have different types). bar[0], however, is a pointer to char. &bar[0] computes the address of that pointer, and yields a result of type pointer to pointer to char. You might find that this post helps understand when pointers and arrays are different (although it doesn't touch on how that affects multi-dimensional arrays and pointers to pointers). |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Incompatible pointer type (double pointer in a function) | Gabriel Margarido | C | 16 | Nov 23rd, 2007 3:04 AM |
| Function pointer to a member function | Jimbo | C++ | 3 | May 12th, 2006 4:53 PM |
| Recommended Practice for returning data from function | Arla | C# | 1 | Aug 16th, 2005 12:21 PM |
| Returning a value from a variable to the main function | colt | C | 3 | Apr 28th, 2005 7:56 AM |
| Returning An Array From a Function | ViZioN | C++ | 5 | Feb 21st, 2005 6:45 PM |