468,456 Members | 1,648 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,456 developers. It's quick & easy.

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 93594
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 NPC403 | last post: by
1 post views Thread by subhajit12345 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.