?
Solved

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

Posted on 2012-09-07
3
Medium Priority
?
746 Views
Last Modified: 2016-02-10
First, I'm very new to programming and C++ so if I made a huge flaw in the code below, forgive me...it'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?
0
Comment
Question by:Mark_Co
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
Hamidreza Vakilian earned 2000 total points
ID: 38378781
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;"
0
 

Author Comment

by:Mark_Co
ID: 38378798
Crap. I knew I was tired and made a stupid mistake. Sorry, and thank you
0
 

Author Closing Comment

by:Mark_Co
ID: 38378806
i apologize for this stupid question. I went back to xcode and got it fixed right away. Going to bed now, hahaha
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question