Re: Converting String to Char
From: Karl Heinz Buchegger (kbuchegg_at_gascad.at)
Date: 03/19/04
- Next message: Hattuari: "Re: Homework: Suppose: All code in header files?"
- Previous message: Marc Schellens: "Re: index from iterator"
- In reply to: seia0106: "Re: Converting String to Char"
- Next in thread: Kevin Goodsell: "Re: Converting String to Char"
- Reply: Kevin Goodsell: "Re: Converting String to Char"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Hattuari: "Re: Homework: Suppose: All code in header files?"
- Previous message: Marc Schellens: "Re: index from iterator"
- In reply to: seia0106: "Re: Converting String to Char"
- Next in thread: Kevin Goodsell: "Re: Converting String to Char"
- Reply: Kevin Goodsell: "Re: Converting String to Char"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|