#include <iostream> #include <string> using namespace std; string mystring1, mystring2, mystring3 = "grové"; int main(){ mystring1 = "grové"; getline( cin, mystring2 ); //Here I type "grové" (without "") cout << "mystring1= " << mystring1 << endl; cout << "mystring2= " << mystring2 << endl; cout << "mystring3= " << mystring3 << endl; return 0; } The output of above code is:
mystring1= grov8
mystring2= grové
mystring3= grov8
although when I cut and paste the code here it comes as:
mystring1= grovΘ
mystring2= grové
mystring3= grovΘ
Why does the content of mystring2 differ from mystring1 and mystring3?
mystring3and any mentions to it, it adds nothing. Also, you're missing#include <string>