Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 19th, 2007, 1:43 AM   #21
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,223
Rep Power: 5 grumpy is on a distinguished road
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).
grumpy is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:20 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC