🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #14587

Re: wchar_t**

#14587
From: Alan Bellingham
Date: Fri, 08 Aug 2003 08:59
51 lines
2005 bytes
"Maurice Anderson" <mauriceanderson@hotmail.com> wrote:

>What is char**.   I know char* is a pointer but what is the extra "*" for?

It's a pointer to a pointer.

For example:

  void
  set_text(char ** text)
  {
     *text = "Hello world";
  }

'text' here is a pointer to a pointer. This means that you have to use
'*' on the variable to get back to the original pointer type.

And what do you use it for? Well, you can pass a pointer to this
function by reference, and the function will update it:

  char* text = NULL;
  set_text(&text);
  puts(text);  // prints out 'Hello world'
  
In terms of your original question, you've probably got something like:

  void
  set_text(BSTR* text)
  {
     *text = ::SysAllocString(L"Hello world");
  }

Note the common pattern:

  SomeType data;
  set(&data);
      |
      `-------.
              |
  void        |
  set(SomeType* data)
  {           |
     ,--------'
     |
     *data = ...;
  }


Alan Bellingham
-- 
alanb@episys.com
Technical Details
Message-ID: <mmo6jv4f1oshr3lbhonksgq3ugc3v2rats@4ax.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3f3340e1$1@newsgroups.borland.com> <oprtkq1wb9ksrh3r@newsgroups.borland.com> <3f334c96@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,957a1a08778b0a57
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-08-08 02:01:33 PST
From: Alan Bellingham <alanb@episys.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: wchar_t**
Date: Fri, 08 Aug 2003 09:59:53 +0100
Reply-To: alanb@episys.com
Message-ID: <mmo6jv4f1oshr3lbhonksgq3ugc3v2rats@4ax.com>
References: <3f3340e1$1@newsgroups.borland.com> <oprtkq1wb9ksrh3r@newsgroups.borland.com> <3f334c96@newsgroups.borland.com>
X-Newsreader: Forte Agent 1.92/32.572
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 193.129.251.130
X-Trace: newsgroups.borland.com 1060333199 193.129.251.130 (8 Aug 2003 01:59:59 -0700)
Lines: 51
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail