Saturday

How to write a console application in C++ with Qt Creator?

Open Qt Creator.
Choose Menu > File > New File or Project.
Choose a template: Other Project > Qt Console Application.
Click Choose button to choose Qt Console Application.
Name the Qt Console Application project as qt_console_app_prj1.
Create the console application in D:\code_qt_folder path. Tick the box to use this path as default project location.
Click Next button.
Make sure Qt 4.7.3 for Desktop MinGW 4.4 (Qt SDK) debug and release boxes are ticked.
Click Next button.
Click Finish button.

Replace the entire main.cpp content with the following code:
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main(int argc, char *argv[])
{
    //Ctrl+/ = toggle between comment and uncomment selection

    string name;
    cout << "Enter your name: ";
    cin >> name; //World
    cout << "Hello, " << name << "!" << endl;

    system("pause");
    return 0;
}

Press Ctrl+S to save this file first.

Press Ctrl+R to run this file to get the Qt Console Application.

Notes:
You must create a project to run cpp files.

No comments:

Measure execution time with Julia, example using sorting algorithms

# random integers between 1 and 100 inclusive, generate thousands of them x = rand ( 1 : 100 , 100000 ) @time sort (x; alg=InsertionSort, r...