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.
Question
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 ?
La solution
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.