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:

If a hater attacked your age and not the goodness of you

Whether young or old, I've always been known what endures. I've known the very idea of people that were all created equal and deserv...