M
last year
Mcountry asked

In C++, why do we add an empty string like " " while printing? If we do not use it, will it cause an error?

Abhay Jajodia
Expert
last year
Abhay Jajodia answered

Hi M Idrees Gul,

It usually will not cause an error. The " " is just a space, used to make the output readable.

Without it, the text prints back to back:

cout << "Hey." << "Are you enjoying the course?";

Output:
Hey.Are you enjoying the course?

With a space in between:

cout << "Hey." << " " << "Are you enjoying the course?";

Output:
Hey. Are you enjoying the course?

So " " is not required for the program to run, it is just for nicer output.

If you have more questions, I am here to help 😊

C++
This question was asked as part of the Learn C++ Basics course.