New user to C++ on a Mac using xcode. Trying to use IDE correctly

First, I'm very new to programming and C++ so if I made a huge flaw in the code below, forgive's possible I screwed up bigtime. I am trying to make a very, very basic program just so I can get started using xcode on my Mac instead of codeblocks on my pc to compile C++ programs

#include <iostream>
using namespace std;

int main(int argc, const char * argv[])
    int a,b,c,d,e,f,g;
    cout << "Enter 6 numbers: ";
    cin >> a >> b >> c >> d >> e >> f >> g;
    cout << a << b;
    return 0;

Open in new window

The above code outputs:
Enter 6 numbers: 

Open in new window

when I type in the 6 numbers ( as '1 2 3 4 5 6')and hit enter, the rest of the program does not run(the   cout << a << b;). I tried running the program from bash also but that too was not working. I'm feeling really dumb right now. Can someone tell me what I'm doing wrong?
Who is Participating?
Hamidreza VakilianConnect With a Mentor Senior iOS DeveloperCommented:
When the program prints "Enter 6 numbers: " you should enter 7 numbers since you have defined 7 int variables (a,b,c,d,e,f,g) in your code and the program expects to get 7 subsequent numbers from input not 6. so type e.g. '1 2 3 4 5 6 7' and you will get the output as:
'12' (one and two numbers without space if you need space between the two numbers you should change "cout << a << b;" line to "cout << a  << " "<< b;"
Mark_CoAuthor Commented:
Crap. I knew I was tired and made a stupid mistake. Sorry, and thank you
Mark_CoAuthor Commented:
i apologize for this stupid question. I went back to xcode and got it fixed right away. Going to bed now, hahaha
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.