Connecting Tech Pros Worldwide Help | Site Map

char* to string

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 15th, 2006, 05:45 AM
Gary Wessle
Guest
 
Posts: n/a
Default char* to string

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, 05:45 AM
Jim Langston
Guest
 
Posts: n/a
Default 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, 06:15 AM
Rolf Magnus
Guest
 
Posts: n/a
Default 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, 04:05 PM
Andrew Koenig
Guest
 
Posts: n/a
Default 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?


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.