Connecting Tech Pros Worldwide Help | Site Map

char* to string

Gary Wessle
Guest
 
Posts: n/a
#1: Nov 15 '06
Hi

class Type {
public:
const char* somefun() const;
....
};

how can I get the output into a string.

Type abc;
const string mystr = abc.somefun();

thanks
Jim Langston
Guest
 
Posts: n/a
#2: Nov 15 '06

re: char* to string


"Gary Wessle" <phddas@yahoo.comwrote in message
news:m37ixxxk8c.fsf@localhost.localdomain...
Quote:
Hi
>
class Type {
public:
const char* somefun() const;
...
};
>
how can I get the output into a string.
>
Type abc;
const string mystr = abc.somefun();
>
thanks
I"m not sure I understand your quesiton. You have somefun that's returning
a char pointer and you want to get it into a string? I think:
std::string Mystring( abc.somefun() );
would do the trick.


Rolf Magnus
Guest
 
Posts: n/a
#3: Nov 15 '06

re: char* to string


Gary Wessle wrote:
Quote:
Hi
>
class Type {
public:
const char* somefun() const;
...
};
>
how can I get the output into a string.
>
Type abc;
const string mystr = abc.somefun();
Which problem did you get when you tried that?

Andrew Koenig
Guest
 
Posts: n/a
#4: Nov 15 '06

re: char* to string


"Gary Wessle" <phddas@yahoo.comwrote in message
news:m37ixxxk8c.fsf@localhost.localdomain...
Quote:
class Type {
public:
const char* somefun() const;
...
};
Quote:
how can I get the output into a string.
Quote:
Type abc;
const string mystr = abc.somefun();
Looks right to me. Have you tried it? Does it fail for some reason?


Closed Thread