cplusplus.com cplusplus.com
cplusplus.com   C++ : Forums : Beginners : How to convert char to string
  Search:
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forums
Forums
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programm...
Articles
Lounge
Jobs

-

post  How to convert char to string

tnjones (38)
Hello,
I have a problem where I need to convert a char to a string and then a string to an int. Any help will be greatly thankful!!!

Thanks in Advance
|
Umz (153)
Have you tried anything yourself? You should start there... when a problem with what you've done comes up post your code and we'll help you through the issues
|
Cerburos (45)
I dont know if this is what you need

typecasting

http://www.cprogramming.com/tutorial/lesson11.html
|
Repentinus (21)
Char to string:
1
2
3
4
5
6
7
#include <sstream>
#include <string>
stringstream ss;
string s;
char c = 'a';
ss << c;
ss >> s;


String to int:
1
2
3
4
5
6
7
#include <sstream>
#include <string>
stringstream ss;
string s;
int n = 1;
ss << n;
ss >> s;
| Last edited on
Cerburos (45)
Repentinus, Thanks for that reply. It tells a noob like me everything I need to know to use it. Thank you. Now I have a piece of code I can try out, experiment with, and learn from.
|
Zaita (1562)
I would've thought:
string mystring = string(char);
was sufficient.
|

This topic is archived - New replies not allowed.
Home page | Privacy policy
© cplusplus.com, 2000-2009 - All rights reserved - v2.2
Spotted an error? contact us