+ 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; }

4th Jan 2019, 4:02 PM
Janna Al-Ward
Janna Al-Ward - avatar
2 Respuestas
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).
4th Jan 2019, 5:47 PM
Théophile
Théophile - avatar
+ 1
Thank you Théophile and Gellert .
4th Jan 2019, 5:50 PM
Janna Al-Ward
Janna Al-Ward - avatar