C++ cout problem

Hi, since a couple days I am finding a problem with cout, it can’t output a string, if i want to output a string i have to write letter by letter like here:
cout << 'H' << 'E' << 'L' << 'O' << endl;
Also when i want to output a string with a variable i have to do this:
cout << 'A= << var <<endl;’
instead of just doing this:
cout << 'A=+var << endl;
Is this a bug? What should I do?
Thank you!

If you want to use a string, you have to use ", like this:

cout << "Hello" << endl;

If you use ', this is a single character.

To output a variable:

cout << "A=" << variable << endl;
2 Likes

Hi Thank you for the reply, I actually got my mistake earlier. But still gonna like it. Thank you anyway!

In C++, single quote and double quote are treated as different.
'a' is a char while "a" is a string.

To print a variable combining with string in one line, you may
cout << "Some text..." << your_desired_variable << endl;