コード例 #1
2
ファイル: Game.cpp プロジェクト: ChrisTrantas/MMOGame
void CreateConsoleWindow(int numLines, int numColumns, int windowLines, int windowColumns)
{
	CONSOLE_SCREEN_BUFFER_INFO coninfo;

	// Get the console and set the number of lines
	AllocConsole();
	GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo);
	coninfo.dwSize.Y = numLines;
	coninfo.dwSize.X = numColumns;
	SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize);

	SMALL_RECT rect;
	rect.Left = 0;
	rect.Top = 0;
	rect.Right = windowColumns;
	rect.Bottom = windowLines;
	SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), TRUE, &rect);

	FILE *stream;
	freopen_s(&stream, "CONIN$", "r", stdin);
	freopen_s(&stream, "CONOUT$", "w", stdout);
	freopen_s(&stream, "CONOUT$", "w", stderr);

	// Prevent accidental console window close
	HWND hwnd = GetConsoleWindow();
	HMENU hmenu = GetSystemMenu(hwnd, FALSE);
	EnableMenuItem(hmenu, SC_CLOSE, MF_GRAYED);
}
コード例 #2
1
ファイル: console.cpp プロジェクト: jennmat/Cinch
	void Console::RedirectStandardIO()
	{
		FILE *in, *out, *err;
		freopen_s(&in, "CONIN$", "rb", stdin);   // reopen stdin handle as console window input
		freopen_s(&out, "CONOUT$", "wb", stdout); // reopen stout handle as console window output
		freopen_s(&err, "CONOUT$", "wb", stderr); // reopen stderr handle as console window output
	}
コード例 #3
1
ファイル: dbg.cpp プロジェクト: w4kfu/hacnpx
VOID MakeConsole(VOID)
{
    DWORD dwMode;
    struct _CONSOLE_SCREEN_BUFFER_INFO sbi;
    HANDLE hStd;
    FILE *fStream;

    //if (!InitializeCriticalSectionAndSpinCount(&CriticalSection, 0x00000400)) {
    //    DbgMsg("[-] InitializeCriticalSectionAndSpinCount failed : %lu\n", GetLastError());
    //}
    //InitializeCriticalSection(&CriticalSection);
    InitCriticalSection();
    if (!AllocConsole()) {
        FreeConsole();
        if (!AllocConsole()) {
            DbgMsg("[+] AllocConsole() failed : %lu\n", GetLastError());
        }
    }
    hStd = GetStdHandle(STD_OUTPUT_HANDLE);
    GetConsoleMode(hStd, (LPDWORD)&dwMode);
    SetConsoleMode(hStd, dwMode & 0xFFFFFFEF);
    GetConsoleScreenBufferInfo(hStd, &sbi);
    sbi.dwSize.Y = 500;
    SetConsoleScreenBufferSize(hStd, sbi.dwSize);
    freopen_s(&fStream, "conin$", "r", stdin);
    freopen_s(&fStream, "conout$", "w", stdout);
    freopen_s(&fStream, "conout$", "w", stderr);
}
コード例 #4
0
ファイル: 39.c プロジェクト: sylvester127/Algorithm
int main()
{
	FILE *f;
	freopen_s(&f, "input.txt", "r", stdin);
	freopen_s(&f, "output.txt", "w", stdout);

	int N, temp;
	int *arr;
	int i, j;

	scanf_s("%d", &N);

	arr = (int *)malloc(sizeof(int)*N);

	for (i = 0; i < N; i++)
	{
		scanf_s("%d", &arr[i]);
	}

	for (i = 0; i < N - 1; i++)
	{
		for (j = 0; j < N - i; j++)
			if (arr[j - 1] > arr[j])
			{
				temp = arr[j - 1];
				arr[j - 1] = arr[j];
				arr[j] = temp;
			}
	}

	for (i = 0; i < N; i++)
		printf("%d ", arr[i]);

	return 0;
}
コード例 #5
0
ファイル: 홀수.c プロジェクト: sylvester127/Algorithm
int main()
{
	FILE *f;
	freopen_s(&f, "input.txt", "r", stdin);
	freopen_s(&f, "output.txt", "w", stdout);

	int n, sum = 0, min = 999, flag = 0;

	for (int i = 0; i < 7; i++)
	{
		scanf_s("%d", &n);

		if (n % 2 == 1)
		{
			sum += n;
			if (min >= n)
				min = n;
			flag = 1;
		}	
	}
	if (flag == 0)
		printf("-1");
	else
		printf("%d %d", sum, min);
	return 0;
}
コード例 #6
0
ファイル: SysConsole.cpp プロジェクト: dotminic/code
		BOOL SysConsole::Open( int x, int y, int w, int h )
		{
			BOOL r = AllocConsole();

			if (!r)
				return r;
			AttachConsole(GetCurrentProcessId());
			MoveWindow(GetConsoleWindow(), x, y, w, h, true);
			m_cinbuf = std::cin.rdbuf();
			m_console_cin.open("CONIN$");
			std::cin.rdbuf(m_console_cin.rdbuf());
			m_coutbuf = std::cout.rdbuf();
			m_console_cout.open("CONOUT$");
			std::cout.rdbuf(m_console_cout.rdbuf());
			m_cerrbuf = std::cerr.rdbuf();
			m_console_cerr.open("CONOUT$");
			std::cerr.rdbuf(m_console_cerr.rdbuf());

			FILE *stream;
			freopen_s(&stream, "conin$", "r", stdin);
			freopen_s(&stream, "conout$", "w", stdout);
			freopen_s(&stream, "conout$", "w", stdout);

			return r;
		}
コード例 #7
0
void Win32AllocateStdioConsole(const char * optArg)
{
   const String optOutFile = optArg;

   const char * conInStr  = optOutFile.HasChars() ? NULL         : "conin$";
   const char * conOutStr = optOutFile.HasChars() ? optOutFile() : "conout$";
   if (optOutFile.IsEmpty()) AllocConsole();  // no sense creating a DOS window if we're only outputting to a file anyway

   // Hopefully-temporary work-around for Windows not wanting to send stdout and stderr to the same file
   String conErrHolder;  // don't move this!  It needs to stay here
   const char * conErrStr = NULL;
   if (optOutFile.HasChars())
   {
      const int lastDotIdx = optOutFile.LastIndexOf('.');

      if (lastDotIdx > 0)
         conErrHolder = optOutFile.Substring(0, lastDotIdx) + "_stderr" + optOutFile.Substring(lastDotIdx);
      else
         conErrHolder = optOutFile + "_stderr.txt";

      conErrStr = conErrHolder();
   }
   else conErrStr = conOutStr;  // for the output-to-console-window case, where redirecting both stdout and stderr DOES work

# if __STDC_WANT_SECURE_LIB__
   FILE * junk;
   if (conInStr)  (void) freopen_s(&junk, conInStr,  "r", stdin);
   if (conOutStr) (void) freopen_s(&junk, conOutStr, "w", stdout);
   if (conErrStr) (void) freopen_s(&junk, conErrStr, "w", stderr);
# else
   if (conInStr)  (void) freopen(conInStr,  "r", stdin);
   if (conOutStr) (void) freopen(conOutStr, "w", stdout);
   if (conErrStr) (void) freopen(conErrStr, "w", stderr);
# endif
}
コード例 #8
0
ファイル: GRIP.cpp プロジェクト: Sosi/grip
/**
 * @function OnInit
 * @brief Initialize GRIP window
 * @date 2011-10-13
 */
bool GRIPApp::OnInit()
{
#ifdef WIN32
	// --- Console ---
	FILE* pFile;
    AllocConsole();
    SetConsoleTitle(L"GRIP Console");
    freopen_s( &pFile, "conin$", "r", stdin );
    freopen_s( &pFile, "conout$", "w", stdout );
    freopen_s( &pFile, "conout$", "w", stderr );
#endif
	// --- Console ---

    if ( !wxApp::OnInit() )
        return false;
    frame = new GRIPFrame(wxT("GRIP"));
	frame->SetFocus();

	AddTabs();

	wxInitAllImageHandlers();
	wxImage gripimg = wxImage(robot_xpm);
	char r,g,b;
	gripimg.InitAlpha();
	for(int i=0; i<16; i++)for(int j=0; j<16; j++){
			r=gripimg.GetRed(i,j);g=gripimg.GetBlue(i,j);b=gripimg.GetGreen(i,j);
			if(r == g && g == b) gripimg.SetAlpha(i,j,255-r);
	}
	wxIcon ico;
	ico.CopyFromBitmap(wxBitmap(gripimg));
	frame->SetIcon(ico);
    frame->Show(true);

    return true;
}
コード例 #9
0
LRESULT CALLBACK SystemClass::MessageHandler(HWND hwnd, UINT umsg, WPARAM wparam, LPARAM lparam)
{
	switch (umsg)
	{
	case WM_CREATE:

		AllocConsole();
		FILE *acStreamOut;
		FILE *acStreamIn;
		freopen_s(&acStreamOut, "CONOUT$", "wt", stdout);
		freopen_s(&acStreamIn, "CONIN$", "r", stdin);
		// Check if a key has been pressed on the keyboard.
	case WM_KEYDOWN:

		// If a key is pressed send it to the input object so it can record that state.
		InputClass::GetInstance()->KeyDown((unsigned int)wparam);
		return 0;

		// Check if a key has been released on the keyboard.
	case WM_KEYUP:
		// If a key is released then send it to the input object so it can unset the state for that key.

		InputClass::GetInstance()->KeyUp((unsigned int)wparam);
		return 0;

		// Any other messages send to the default message handler as our application won't make use of them.
	default:
		return DefWindowProc(hwnd, umsg, wparam, lparam);
	}
}
コード例 #10
0
ファイル: scCore.cpp プロジェクト: kidsang/SaberCore2
scCore::scCore(string const& cfgFilePath, bool useConsole/*= false*/)
	: mUseConsole(useConsole), mRenderer(0), mGameWorldManager(0), mTimeLineManager(0),
	mEventRouter(0)
{
	if (mUseConsole)
	{
		// 创建控制台窗口,并将标准输入流,标准输出流和标准错误流重定向至控制台
		if( !AllocConsole() )
			MessageBoxA(NULL, "控制台生成失败。", NULL, 0); 
		SetConsoleTitleA("Debug Window"); 
		freopen_s(&fpDebugOut, "CONOUT$","w", stdout); 
		freopen_s(&fpDebugIn, "CONIN$", "r", stdin); 
		freopen_s(&fpDebugErr, "CONOUT$","w", stderr); 
		setlocale(LC_ALL, "chs");
		std::cout << "控制台已创建!" << std::endl;
	}

	// 初始化渲染子系统
	mRenderer = new scRenderer("resources_d.cfg", "plugins_d.cfg");
	// 初始化输入子系统
	u32 windowHnd = 0;
	mRenderer->getOgreRoot()->getAutoCreatedWindow()->getCustomAttribute("WINDOW", &windowHnd);
	u32 winWidth, winHeight, colDepth;
	i32 winLeft, winTop;
	mRenderer->getOgreRoot()->getAutoCreatedWindow()->getMetrics(winWidth, winHeight, colDepth, winLeft, winTop);
	mInputManager = new scInputManager(windowHnd, winWidth, winHeight);
	// 初始化事件路由器
	mEventRouter = new scEventRouter();
	// 初始化游戏世界管理类
	mGameWorldManager = new scGameWorldManager();
	// 初始化动画管理类
	mAnimationManager = new scAnimationManager();


	// 创建时间轴管理类
	mTimeLineManager = new scTimeLineManager();
	// 创建渲染和输入时间轴,60hz
	scTimeLinePtr tl = mTimeLineManager->createTimeLine("Render", 60);
	tl->addRunCallBack("Render", [&](u32 dtms)->bool{return mRenderer->_run(dtms);});
	tl->addRunCallBack("Input", [&](u32 dtms)->bool{mInputManager->_run(); return true;});
	// 创建动画时间轴,60hz
	tl = mTimeLineManager->createAnimationTimeLine("Animation", 60);
	// 创建事件路由时间轴, 无时间间隔(新线程)
	tl = mTimeLineManager->createTimeLine("Event", 1000, 0, true);
	tl->addRunCallBack("Event", [&](u32 dtms)->bool{mEventRouter->_run(); return true;});
	// 创建游戏世界时间轴, 60Hz
	tl = mTimeLineManager->createTimeLine("GameWorld", 60);
	tl->addRunCallBack("GameWorld", [&](u32 dtms)->bool{return mGameWorldManager->_run(dtms);});
	// 创建背景加载时间轴,10Hz(新线程)
	//tl = mTimeLineManager->createTimeLine("BackgroundLoading", 10, 0, true);

	// 测试一下
	scGameWorldPtr gw(new scGameWorld("test", "testini.lua", "iniScene"));
	mGameWorldManager->addGameWorld(gw->getName(), gw);
	mGameWorldManager->initializeGameWorld("test");
}
コード例 #11
0
ファイル: Util.cpp プロジェクト: NitroXenon/LOLOffsets
void CUtil::FAllocConsole() {

	AllocConsole();
	FILE* f1;
	FILE* f2;
	FILE* f3;
	freopen_s(&f1, "CONOUT$", "wb", stdout);
	freopen_s(&f2, "CONOUT$", "wb", stderr);
	freopen_s(&f3, "CONIN$", "rb", stdin);
}
コード例 #12
0
ファイル: Console.cpp プロジェクト: Ser0ja/PacketFramework
void Console::Initialize()
{
    // Create console window
    FreeConsole();
    AllocConsole();

    // Redirect streams to the newly created console
    FILE* console = nullptr;
    freopen_s(&console, "CONIN$", "r", stdin);
    freopen_s(&console, "CONOUT$", "w", stdout);
    freopen_s(&console, "CONOUT$", "w", stderr);
}
コード例 #13
0
// Create console screen buffer and set it to application
bool CTeslaDecrypterApp::SetConsoleBuffers() {
	FILE * fOut = NULL, *fIn = NULL, *fErr = NULL;
	freopen_s(&fOut, "CON", "w", stdout ) ;
	freopen_s(&fIn, "CON", "r", stdin ) ;
	freopen_s(&fErr, "CON", "w", stderr ) ;
	std::cin.clear();
	std::cout.clear();
	std::cerr.clear();
	std::ios::sync_with_stdio();

	rewind(stdout);
	rewind(stdin);
	return (fOut != NULL);
}
コード例 #14
0
ファイル: main.cpp プロジェクト: jg-maon/kadai
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	//コンソール画面の呼び出し
	AllocConsole();
	FILE* fp;
	freopen_s(&fp, "CONOUT$", "w", stdout);
	freopen_s(&fp, "CONIN$", "r", stdin);

	Application app(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
	if (!app.Run())return 1;


	FreeConsole();//コンソールの解放
	return 0;
}
コード例 #15
0
ファイル: main.cpp プロジェクト: ChiLaX/Community-Trainer
int StartUp()
{
	AllocConsole();
	AttachConsole(GetCurrentProcessId());

	FILE* fp = NULL;
	freopen_s(&fp, "CON", "w", stdout);
	freopen_s(&fp, "CON", "w", stderr);

	char cc[128];
	sprintf_s(cc,"Server: %i",GetCurrentProcessId());
	SetConsoleTitleA(cc);

	return 1;
}
コード例 #16
0
ファイル: BoxCar.cpp プロジェクト: shtras/BlindAM
int main(int argc, char** argv)
#endif
{
  Logger::getInstance().log(INFO_LOG_NAME, "Application started. Hello, World!");
  Logger::getInstance().log(INFO_LOG_NAME, CString("Application version: ") + Version + " " + CString(BUILD_STR));
#if defined(WIN32) && defined(DEBUG)
  AllocConsole();
  FILE* stream = NULL;
  errno_t err = freopen_s(&stream, "CON", "w", stdout);
#endif


  BoxCar& game = BoxCar::getInstance();
  bool res = game.init();
  if (res) {
    Logger::getInstance().log(INFO_LOG_NAME, "Initialization successfully completed");
    game.run();
  } else {
    Logger::getInstance().log(ERROR_LOG_NAME, "Something went horribly wrong. Look above for details.");
  }

#if defined(WIN32) && defined(DEBUG)
  FreeConsole();
#endif
  Logger::getInstance().log(INFO_LOG_NAME, "Application ended. Bye!");
}
コード例 #17
0
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR    lpCmdLine,
                     int       nCmdShow)
{
	int exitcode = 0;
	//Allocate a console window
	//so that messages can be redirected to stdout
	if (!AllocConsole())
	{
		ErrorExit(TEXT("AllocConsole"));
	}

	FILE* pf_out;
	freopen_s(&pf_out, "CONOUT$", "w", stdout);

	PrintUsage();

	//Create the application instance
	OGLApplication* myapp = OGLApplication::CreateApplication(hInstance);

	exitcode = myapp->Run();

	myapp->DestroyApplication();

	fclose(pf_out);

	//Free the console window
	if (!FreeConsole())
	{
		ErrorExit(TEXT("FreeConsole"));
	}

	return exitcode;
}
コード例 #18
0
ファイル: main.cpp プロジェクト: xu-wang11/Permutation
void init()
{
	freopen_s(&output, "output.txt", "w", stdout);
	int n = 0;
	scanf_s("%d", &n);
	len = n;
}
コード例 #19
0
ファイル: 16.c プロジェクト: sylvester127/Algorithm
int main()
{
	FILE *f;
	freopen_s(&f, "input.txt", "r", stdin);
	
	char ch;
	int i;

	fseek(f, 2, SEEK_SET);
	scanf_s("%c", &ch);
	
	freopen_s(&f, "output.txt", "w", stdout);
	printf("%c %d", ch,ch);

	return 0;
}
コード例 #20
0
ファイル: Main.cpp プロジェクト: nhnponyo/AmutenaPizza
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdParam, int nShowCmd ){
#ifdef _DEBUG
	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_LEAK_CHECK_DF);
	//_CrtSetBreakAlloc( );
	AllocConsole();
	FILE* console;
	freopen_s( &console, "CONOUT$", "wt", stdout );

	printf_s("Console Open \n");
#endif 


	NNApplication* Application = NNApplication::GetInstance();
	Application->Init( L"Amutena Pizza", 1024, 640, D2D );
	
	NNSceneDirector::GetInstance()->ChangeScene( CMainTitleScene::Create());
	
	Application->Run();
	Application->Release();

#ifdef _DEBUG
	FreeConsole();
#endif

	return 0;
}
コード例 #21
0
ファイル: IEX_System.cpp プロジェクト: TheOSF/o.s.f
void iexSystem::OpenDebugWindow()
{
#ifdef _DEBUG
	AllocConsole();
	freopen_s( &DebugFP, "CON", "w", stdout);
#endif
}
コード例 #22
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline, int iCmdshow)
{
#ifdef _DEBUG
	FILE *stream;	//debug下需要一个控制台输出调试信息
	AllocConsole();
	freopen_s(&stream, "CONOUT$", "w", stdout);
#endif
	DrawFunction my_d3d_haha;

	my_d3d_haha.WinMain_InitWindow(hInstance, iCmdshow);

	if (FALSE == my_d3d_haha.Init()) return FALSE;
	else printf("This is the template_3 for my DirectX_11 project \n");
		//创建基本的D3D对象,设备,交换链,视窗等

	if (FAILED(my_d3d_haha.CompileTheShader())) return FALSE;
	else printf("CompileTheShader ----OK!\n");

	if (FAILED(my_d3d_haha.CreateGraph()))return FALSE;
	else printf("CreateGraph ----OK!\n");

	my_d3d_haha.Run();

	return 0;
}
コード例 #23
0
ファイル: interface.cpp プロジェクト: tnuvoletta/Principia
void InitGoogleLogging() {
  if (google::IsGoogleLoggingInitialized()) {
    LOG(INFO) << "Google logging was already initialized, no action taken";
  } else {
#ifdef _MSC_VER
    FILE* file;
    freopen_s(&file, "stderr.log", "w", stderr);
#else
    std::freopen("stderr.log", "w", stderr);
#endif
    google::SetStderrLogging(google::INFO);
    google::SetLogDestination(google::FATAL, "glog/Principia/FATAL.");
    google::SetLogDestination(google::ERROR, "glog/Principia/ERROR.");
    google::SetLogDestination(google::WARNING, "glog/Principia/WARNING.");
    google::SetLogDestination(google::INFO, "glog/Principia/INFO.");
    FLAGS_v = 1;
    // Buffer severities <= |INFO|, i.e., don't buffer.
    FLAGS_logbuflevel = google::INFO - 1;
    google::InitGoogleLogging("Principia");
    LOG(INFO) << "Initialized Google logging for Principia";
    LOG(INFO) << "Principia version " << base::kVersion
              << " built on " << base::kBuildDate;
    // TODO(egg): by (compiler) for (ARCH, OS).
  }
}
コード例 #24
0
ファイル: 3D_Arkanoid.cpp プロジェクト: mastrayer/3D_Arkanoid
int APIENTRY WinMain(HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	LPSTR lpszCmdParam,
	int nCmdShow)
{
#ifdef DEBUG
	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
	//_CrtSetBreakAlloc(157);

	AllocConsole();
	FILE* console;
	freopen_s(&console, "CONOUT$", "wt", stdout);
#endif

	CGameManager *GameManager = CGameManager::GetInstance();
	GameManager->initialize(600, 600);
	GameManager->changeScene(new CStartScene());
	GameManager->run();

#ifdef DEBUG
	FreeConsole();
#endif

	return 0;
}
コード例 #25
0
ファイル: console.cpp プロジェクト: BattleNWar/YDWE
void enable()
{
    HWND h = ::GetConsoleWindow();

    if (h)
    {
        ::ShowWindow(h, SW_SHOW);
    }
    else
    {
        FILE* new_file;
        ::AllocConsole();
        freopen_s(&new_file, "CONIN$", "r", stdin);
        freopen_s(&new_file, "CONOUT$", "w", stdout);
        freopen_s(&new_file, "CONOUT$", "w", stderr);
    }
}
コード例 #26
0
ファイル: 43.c プロジェクト: sylvester127/Algorithm
int main()
{
	FILE *f;
	freopen_s(&f, "input.txt", "r", stdin);
	freopen_s(&f, "output.txt", "w", stdout);

	char ch[100];
	int i;

	gets_s(ch, sizeof(ch));

	for (i = strlen(ch)-1; i >= 0; i--)
	{
		printf("%c", ch[i]);
	}
	return 0;
}
コード例 #27
0
ファイル: 19.c プロジェクト: sylvester127/Algorithm
int main()
{
	FILE *f;
	freopen_s(&f, "input.txt", "r", stdin);
	freopen_s(&f, "output.txt", "w", stdout);

	char a[10], b[10];
	int c;

	gets_s(a, sizeof(a));
	gets_s(b, sizeof(b));
	scanf_s("%d", &c);

	strcat_s(a, sizeof(a), b);
	printf("%d",atoi(a) + c);
	return 0;
}
コード例 #28
0
ファイル: main.cpp プロジェクト: w4kfu/whook
void init_console(void)
{
  int Mode;
  struct _CONSOLE_SCREEN_BUFFER_INFO sbi;
  HANDLE    Hstd;
  FILE      *stream;

  Hstd = GetStdHandle(STD_INPUT_HANDLE);
  AllocConsole();
  GetConsoleMode(Hstd, (LPDWORD)&Mode);
  SetConsoleMode(Hstd, Mode & 0xFFFFFFEF);
  GetConsoleScreenBufferInfo(Hstd, &sbi);
  sbi.dwSize.Y = 4096;
  SetConsoleScreenBufferSize(Hstd, sbi.dwSize);
  freopen_s(&stream, "conin$", "r", stdin);
  freopen_s(&stream, "conout$", "w", stdout);
  freopen_s(&stream, "conout$", "w", stderr);
}
コード例 #29
0
int main()
{
	FILE *f;
	freopen_s(&f, "input.txt", "r", stdin);
	freopen_s(&f, "output.txt", "w", stdout);

	int tall[7];

	for (int i = 0; i < 7; i++)
		scanf_s("%d", &tall[i]);

	qsort(tall, sizeof(tall) / sizeof(int), sizeof(int), compare);

	for(int i =6;i>=5;i--)
		printf("%d\n", tall[i]);

	return 0;
}
コード例 #30
-1
ファイル: console.cpp プロジェクト: BrotherhoodOfHam/Engine3D
	void consoleOpen()
	{
		//Check if application does not have a console already open
		if (GetStdHandle(STD_OUTPUT_HANDLE) == NULL)
		{
			AllocConsole();

			if (int code = AttachConsole(GetCurrentProcessId()))
			{
				tserror("AttachConsole failed with code %", code);
			}

			FILE* fp = nullptr;
			errno_t e = 0;

			tsassert(!(e = freopen_s(&fp, "CONOUT$", "w", stdout)));
			tsassert(!(e = freopen_s(&fp, "CONIN$", "r", stdin)));
			//tsassert(!(e = freopen_s(&fp, "CONERR$", "w", stderr))); //todo: fix opening of stderr

			//Synchronise with standard library console functions/objects (cout/cin/cerr)
			std::ios::sync_with_stdio();

		}

		ts::global::getLogger().addStream(&getConsoleStreamInstance());
	}