Answer the question
In order to leave comments, you need to log in
How to print string value in C++ console?
There is a variable of type string. It is required to display the value of this variable on the screen. cout does not work with the standard stream.
#include <iostream>
using namespace std;
int main()
{
string str = "Hello";
cout << str << endl;
return 0;
}
Answer the question
In order to leave comments, you need to log in
The matter is that at you msvc the compiler.
It's a bit special, and the << and >> operators for strings are defined separately from iostream .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question