mardi 16 novembre 2021

Difference between " , " and " << " in cout in c++? [duplicate]

code :

#include <iostream> 
using namespace std;
int main() 
{ 
    int i = 1;
    cout << "hello " << i  << " end" ;
    return 0; 
} 

OUTPUT : hello 1 end
this works fine but

#include <iostream> 
using namespace std;
int main() 
{  
    int i = 1;
    cout << "hello " , i  , " end" ;
    return 0; 
} 

OUTPUT: hello
why the above terminates with printing hello only?

Aucun commentaire:

Enregistrer un commentaire