Re: Converting String to Char

From: Karl Heinz Buchegger (kbuchegg_at_gascad.at)
Date: 03/19/04


Date: Fri, 19 Mar 2004 11:02:21 +0100

seia0106 wrote:
>
> Karl Heinz Buchegger <kbuchegg@gascad.at> wrote in message news:<4059C6AD.96F24259@gascad.at>...
>
> > But the question arises: Why don't you rewrite the function Load such
> > that it takes a std::string as its first argument?
> Thank you. That solved the problem.
> Regarding your question. I can not make changes to Load() because it
> is part of a library.

In this case you have a problem.
c_str() gives a const char*
but your Load function wants an unsigned char* (which is not const).

You now have 4 options:
* create a copy of the string in dynamic memory and pass a pointer
  to that to the Load function
* if you are 100% sure that the function will not alter the passed characters
  you can cast away the const (by using a const_cast)
* use a different library
* contact the author of the library and ask him to change the argument list.

-- 
Karl Heinz Buchegger
kbuchegg@gascad.at


Relevant Pages

  • Re: Help with WSH Script
    ... Since Outlook Express can't be uninstalled the second condition holds ... ' Load all applicable default values from both Outlook Express and Internet Information Services ... ' Load configuration default values from the local Internet Information Service ... Const cdoOutlookExpress = 2 ...
    (microsoft.public.scripting.wsh)
  • Another technical question
    ... Some special levels are refusing to load, ... are affected based on their position in the alphabet. ... dlb *fd; ... const char *name, *mode; ...
    (rec.games.roguelike.nethack)
  • RE: Yikes! Where is that initialization code in ASPNET 2.0?
    ... doesn't the specific load function has the signature "handles Page_Load" ... > private void InitializeComponent() ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Counting 1-6 instead of 0-9 with a 74LS192 / 74LS47
    ... >>The 74LS192 has a parallel load function. ... Sadly, the load function is active low, so you ... so I don't know if there are strange glitches. ...
    (sci.electronics.basics)
  • Re: Counting 1-6 instead of 0-9 with a 74LS192 / 74LS47
    ... >The 74LS192 has a parallel load function. ... Sadly, the load function is active low, so you ... so I don't know if there are strange glitches. ... The 192 has an asynchronous parallel load, ...
    (sci.electronics.basics)