Connecting Tech Pros Worldwide Help | Site Map

char* to string

  #1  
Old November 15th, 2006, 06:45 AM
Gary Wessle
Guest
 
Posts: n/a
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
  #2  
Old November 15th, 2006, 06:45 AM
Jim Langston
Guest
 
Posts: n/a

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.


  #3  
Old November 15th, 2006, 07:15 AM
Rolf Magnus
Guest
 
Posts: n/a

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?

  #4  
Old November 15th, 2006, 05:05 PM
Andrew Koenig
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert char * to string object mamul answers 3 November 7th, 2008 02:19 PM
char[] to String^ ACSS answers 4 May 19th, 2007 07:24 PM
convert (single) char to string Zytan answers 5 March 5th, 2007 12:45 AM
convert char to string Joah Senegal answers 2 September 25th, 2006 06:25 PM
Concatenate char to String Poewood answers 2 November 17th, 2005 03:11 PM