Reputation: 53
I must write some C++ on Ubuntu Linux. After many searches I found Qt Creator IDE and G++ compiler. So, the problem is: how to run a C++ program and show console black window? For example, how can I get result from this code :
#include <QtCore/QCoreApplication>
#include <iostream>
using namespace std;
int main()
{
cout << "Hello";
int a[5];
cout << "Enter 5 numbers";
for(int i=0;i<5;i++)
cin >> a[i];
for(int i=0;i<5;i++)
cout << a[i] << " ";
}
I am very in a hurry and I will be very thankful for your answer.
I changed code to this:
#include <QtCore/QCoreApplication>
#include <iostream>
using namespace std;
int main()
{
// QCoreApplication a(argc, argv);
cout<<"Hello";
int a[5];
cout<<"Enter 5 numbers";
for(int i=0;i<5;i++)
cin>>a[i];
for(int i=0;i<5;i++)
cout << a[i] << " " << flush;
// return a.exec();
}
but still isn't working. I enter each number in one line, is it correct? How can I enter data for array in true way?
Upvotes: 0
Views: 4174
Reputation: 116
There is a checkbox "Run in terminal" in the run configurations (left rim, "Projects" tab, "Run", "Run Configuration"). If you check that you get an external terminal opened, by default xterm. You can configure another terminal in the lobal setting ("Tools", "Options", "Environment", "General", "System")
Upvotes: 2
Reputation: 9711
Well... there is the play button that will run your application. On lowest-right part of QTCreator, there is a tab "3 application output" that will show you the output.
If you want to run the application in a console without QtCreator, go to the folder where you have your source code. There should be the executable that you can run with
./excutable_name
Upvotes: 3