+ 1
What's the error with this code?
#include<iostream> #include<string> using namespace std; int main() { string mystring='This is a string'; cout<<mystring; return 0; }
2 Answers
0
You are using ' to define a string instead of "
So it is:
string mystring ="This is a string"
' is used to define a char (single character).
+ 1
Thank you Théophile and Gellert .