std::cout


Can somebody explain what is happening in the cout stamenent in the following piece of code ? how is it working ??

1
2
3
4
5
6
7
8
9
10
#include <iostream>

int main()
{

   std::cout<<"cell",
    "cell2";
    
    return 0;
}


It outputs cell and then it ignores everything after that. It's basically the same as
1
2
std::cout << "cell";
"cell2";
It uses comma operator. Which works like "Execute left side argument, then execute right hand argument and return the result of execution"

So in your case it works as: "Output cell, then return string literal cell2 to... nothing"
Topic archived. No new replies allowed.