char* to string

G

Gary Wessle

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
 
J

Jim Langston

Gary Wessle said:
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.
 
R

Rolf Magnus

Gary said:
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,145
Latest member
web3PRAgeency
Top