how to print a string to console in c++
how to print a string to console in c++
yes its possible to print a string to the console.
#include stdafx.h
#include <string>
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string strMytestString(hello world);
cout << strMytestString;
return 0;
}
stdafx.h isnt pertinent to the solution, everything else is.
All you have to do is add:
#include <string>
using namespace std;
at the top.
(BTW I know this was posted in 2013 but I just wanted to answer)
how to print a string to console in c++
Visual Studio does not support std::cout as debug tool for non-console applications
– from Marius Amado-Alves answer to How can I see cout output in a non-console application?
Which means if you use it, Visual Studio shows nothing in the output window (in my case VS2008)