I\'m working with a C++ Console Application in Visual Studio 2013, working on Windows.
First I detached the console using FreeConsole, it works; then, c
FreeConsole
Remove the AllocConsole call before AttachConsole.
From the documentation: A process can be attached to at most one console. If the calling process is already attached to a console, the error code returned is ERROR_ACCESS_DENIED (5).