Syntax problem with C ++

I'm trying to take multiple letters as input and then print them in the order given below:

#include<iostream>
using namespace std;
void main()
{
    char aaa, bbb, ccc;
    cout << "input 3 letters ";
    cin >> aaa >> bbb >> ccc;

    cout <<  aaa "   " << bbb "   " << ccc endl;
}

      

I'm trying to make a space between each variable, but it doesn't work.

This also doesn't work:

        cout <<  aaa <<"   " << bbb <<"   " << ccc endl;

      

PS: isn't it ok to ask questions about syntax problems?

+3


source to share


2 answers


Place <<

between everything in the expression cout

. You still haven't met before endl

.

cout <<  aaa <<"   " << bbb <<"   " << ccc << endl;
                                           ^^

      



PS: isn't it ok to ask questions about syntax problems?

Yes, it's okay. But if the answer is that this is a simple mistake, the question will probably be closed as it won't be useful to others.

+3


source


This should work:



cout <<  aaa << "   " << bbb << "   " << ccc << endl;

      

+2


source







All Articles