Thanks for helping Pete...

Adriano, maybe you could describe the scenario you are trying to cover, and
what's your approach (where you are trying this specific function), this
could help us understand better your issue, and maybe suggest other/better
approaches.

On 1/25/07, Pete Robbins <[EMAIL PROTECTED]> wrote:

OK. I have to ask.... what function are you calling that takes a char*? Is
there an equivalent that takes const char*?

Cheers,


On 25/01/07, Adriano Crestani <[EMAIL PROTECTED]> wrote:
>
> I'm trying to use a function that requires a char* not const as a
> paremeter.
> I think strdup will help a lot, thanks ; )
>
> Adriano Crestani
>
> On 1/25/07, Pete Robbins <[EMAIL PROTECTED]> wrote:
> >
> > On 25/01/07, Adriano Crestani <[EMAIL PROTECTED]> wrote:
> > > I'm begginer with C++ and I would like to know the best way to
obtain
> a
> > > char* from a string object, for example:
> > >
> > > string name = "Alice";
> > > char* namePtr = (char*) string; // this is not possible : (
> > >
> > > Obs.: I'm needing a char* and not a const char* pointer
> > >
> > > Thanks.
> > >
> > > Adriano Crestani
> > >
> > >
> >
> > std::string has a .c_str() method to return the const char*
> > const char* namePtr = name.c_str();
> >
> > Why do you need char* and not const char*? You could cast the value to
> > char* but it is const for a good reason... you should not use c
> > functions to manipulate the characters in std:string!
> >
> > You can take a copy of the string using strdup.
> >
> > Cheers,
> >
> > --
> > Pete
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>


--
Pete




--
Luciano Resende
http://people.apache.org/~lresende

Reply via email to