GUI applications are started without a console and stdin, stdout and stderr are not connected to anything.
A convenient way to see error messages from GUI applications is to use the Windows API function OutputDebugString. Messages written with this function will be visible when the application is run under a debugger and, when not debugging, can be viewed using Sysinternals DebugView utility.
A GUI application can allocate a console and connect the stdin, stdout and stderr streams so that console functions can be used. The console is obtained with AllocConsole and the handles are connected with freopen or the secure (_s) variants. For example,
Connect streams for console I/O -
FILE *fpstdin = stdin, *fpstdout = stdout, *fpstderr = stderr;
// Initialize for console i/o
freopen_s(&fpstdin, "CONIN$", "r", stdin);
freopen_s(&fpstdout, "CONOUT$", "w", stdout);
freopen_s(&fpstderr, "CONOUT$", "w", stderr);