Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mgoff121

macrumors newbie
Original poster
Aug 29, 2011
2
0
I am having problems with the console window reading input. As an example, when I run the program below, the console window will ask for the width only. The program will continue running indefinitely and never ask for the length. Please advise. When I run the program from the terminal, there are no problems.

#include <iostream>
using namespace std;

int main(){
double width,length;
cout << "Enter width of rectangle ";
cin >> width;
cout << "Enter length of rectangle ";
cin >>length;
cout << " Area is " << width*length << endl;
}

Thanks for the help!
 
The code you posted works fine, when I compiled and executed it in the terminal.

Are you building and running it in XCode? - Though that shouldn't make a difference. Is this really the code you have in the source file (copy-and-pasted)?
 
Under XCode 4.2 (beta), I can't replicate your problem.

I do remember people complaining about the console not behaving correctly in earlier versions, maybe even before XCode 4.

If XCode isn't working out for you with C++, perhaps try Eclipse.
 
The code you posted works fine, when I compiled and executed it in the terminal.

Are you building and running it in XCode? - Though that shouldn't make a difference. Is this really the code you have in the source file (copy-and-pasted)?

Yes I am building and running it in Xcode version 4.1. This is the exact code I have in the source file. I know the code works, because I can run it directly from the terminal with no problems.
 
Yes I am building and running it in Xcode version 4.1. This is the exact code I have in the source file. I know the code works, because I can run it directly from the terminal with no problems.

Ok. Sorry, I missed that part in your original post.

On Snow Leopard it seems I am stuck with XCode 4.0.2. :-(
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.