OSError: [WinError 6] 句柄无效

OSError: [WinError 6] 句柄无效

Exception ignored in: <_io.TextIOWrapper name='' mode='w' encoding='utf-8'>

 

void OpenConsole()

{

	// create a console

	AllocConsole();

	FILE* stream;

	freopen_s(&stream, "CON", "r", stdin); //

	freopen_s(&stream, "CON", "w", stdout); //



	SetConsoleTitleA("Information output"); //



	HANDLE _handleOutput;

	_handleOutput = GetStdHandle(STD_OUTPUT_HANDLE);



	// FreeConsole();

}

 

解决方法:只调用AllocConsole();就可以了

头文件是#include

你可能感兴趣的:(c++)