Using the console in a GUI app in windows, only if its run from a console

前端 未结 4 1350
庸人自扰
庸人自扰 2020-12-09 22:46

My application is a GUI app that has helpful (though optional) information through the terminal (via cout).

In Windows I either have a console appear (by compiling a

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-09 23:24

    you can create an application in console that get a line using argc and prints it;

    ////
    int main(int argc, char *argv[])
    {
        //here print argv....using cout or printf
    }
    

    save the file as console.exe in the folder of your app. now in your app if you want to see any line in console you can call the command

    system("console.exe this is the line i want to print and see in console");
    

提交回复
热议问题