Monday, 2 September 2013

using `?:` in the output stream

using `?:` in the output stream

I want to integrate the ?: operator in the output stream. Here is code
bool a;
for (int i = 0; i < 10; i++ ) {
a = rand() % 2;
std::cout << "a= " << (a) ? "true\n" : "false\n";
}
But the output is
a= 1a= 0a= 1a= 1a= 1a= 1a= 0a= 0a= 1a= 1
The problem is, there are no new line and string. What should I do?

No comments:

Post a Comment