Programming/C/C++

Convert char* to string

blueasa 2012. 1. 19. 11:32
1
2
3
4
5
6
7
8
9
10
11
#include<string>
#include<iostream>

int main()
{
const char* charString= "Eggs on toast.";
 std::string someString(charString);

 std::cout << someString;
 return 0;
}

1
2
char *cStr = "C++";
std::string Str = std::string(cStr);


출처 :  http://www.cplusplus.com/forum/general/41912/
반응형