471,076 Members | 1,195 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,076 software developers and data experts.

convert char to string

Hello I need to convert a chat to a string... but I don't know how to do
this. i;ve searched the internet but I've only find some code to convert
char * to string or char [] to string....

but I just need char to string.

Anyone knows how to do this ?

thanks!!!!
Sep 25 '06 #1
2 93768
Joah Senegal wrote:
Hello I need to convert a chat to a string... but I don't know how to
do this. i;ve searched the internet but I've only find some code to
convert char * to string or char [] to string....

but I just need char to string.

Anyone knows how to do this ?
char c('A');
std::string s(1, c); // s now has "A"

or

char c('A');
std::string s(&c, 1); // s now has "A"

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Sep 25 '06 #2
"Victor Bazarov" <v.********@comAcast.netwrote in message
news:ef**********@news.datemas.de...
Joah Senegal wrote:
>Hello I need to convert a chat to a string... but I don't know how to
do this. i;ve searched the internet but I've only find some code to
convert char * to string or char [] to string....

but I just need char to string.

Anyone knows how to do this ?

char c('A');
std::string s(1, c); // s now has "A"

or

char c('A');
std::string s(&c, 1); // s now has "A"

V
Or

char c('A');
std::string s;
s = s + c;

s now has "A"
Sep 25 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by IamZadok | last post: by
7 posts views Thread by MilanB | last post: by
15 posts views Thread by Yifan | last post: by
12 posts views Thread by Brian Henry | last post: by
2 posts views Thread by Steve Kershaw | last post: by
5 posts views Thread by Zytan | last post: by
12 posts views Thread by Peter | last post: by
14 posts views Thread by rtillmore | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.