79652163

Date: 2025-06-04 05:36:04
Score: 1
Natty:
Report link

Decide whether to run the command line or the GUI based on the input parameters

Before run commandline,i call this function

#ifdef _WIN32
#    include <windows.h>
#    include <fcntl.h>
#    include <io.h>
#endif

void attachConsole()
{
#ifdef _WIN32
    if (AttachConsole(ATTACH_PARENT_PROCESS))
    {
        FILE* fDummy;
        freopen_s(&fDummy, "CONOUT$", "w", stdout);
        freopen_s(&fDummy, "CONOUT$", "w", stderr);
        freopen_s(&fDummy, "CONIN$", "r", stdin);
        std::ios::sync_with_stdio();
    }
#endif
}

But console output is flowing:

enter image description here

exit immediately after the program executes the command-line logic without any extra blank lines or repetitive output. but it go wrong!

Reasons:
  • Blacklisted phrase (1): enter image description here
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: ives-wpz