문제

I have a code :

#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
    cout<<"Hello World!";
    getch();
    return 0;
}  

can i get back the string "Hello World!" in some char or string variable ?

도움이 되었습니까?

해결책

No, but you can use string streams to achieve that effect:

#include <iostream>
#include <sstream>

std::ostringstream oss;

oss << "Hello World!";

std::cout << oss.str();

Now oss.str() still contains the string you built.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top