views:

812

answers:

2

Hello,

For school, we use C++ as the language of choice. I am currently using QtCreator as an IDE, and for its GUI library, it is wonderful. The school is using Visual Studio.

However, most of the programs we are writing make use of cin and cout for input/output. cout works fine as output, as you can see what it puts out in the application output, but there is no way to provide to cin as if it were on a console, like Visual Studio uses for its C++.

An example:

#include <iostream>
#include <string>
using namespace std;
int main() {
    string name;
    cout << "Enter name: ";
    cin >> name;
    cout << "Your name is " << name << endl;
}

Is there a way to use a console or provide input to cin like in Visual Studio?

I am currently running OS X Leopard, if it matters.

Thanks!

+1  A: 

If you're doing "console"-style apps with no GUI, Qt Creator may not be the most appropriate IDE -- why not try Apple's own XCode, which probably comes on your OS DVD (as a separate installer), and worst-case can be freely downloaded by registering at Apple Developer Connection?

Edit: as the OP indicates that all they need is the location to Mac's terminal app, that's easy: it's /Applications/Utilities/Terminal.app.

Alex Martelli
I do have that installed, but I have not used it yet. How do you just make a simple project to do what I'm looking for?
Austin Hyde
With XCode? Start it up, select File->New Project and from the list of options select Command Line Utility \ C++ Tool
Dan O
+1  A: 

Ok, I got it.

Under Project -> Run Settings there is a checkbox called "Run in Terminal"

Check it, and it will run in the terminal. The only problem is, I don't know what the name/location of the terminal on mac is. It's currently looking for xterm -e, which is the Linux terminal. That setting is under Preferences -> Environment.

What's the Mac's?

Austin Hyde