Пример #1
0
int main(){

#ifdef DEBUG 
    UnitTests();
#endif

  std::ifstream fIn("fact4.in");;
  std::ofstream fOut("fact4.out");
  if (!fIn.is_open() || !fOut.is_open()) {
      std::cerr << "Failed to open file";
      goto Return;
  }

  int nInput;
  fIn >> nInput;
  
  fOut << SpecialFactorial(nInput, NumberOfFives(nInput)) << std::endl;

Return:
  if (fIn.is_open()){
      fIn.close();
  }
  if (fOut.is_open()){
      fOut.close();
  }
  fOut.close();
  
  return 0;
}
Пример #2
0
main()
{
	bool Enigmatic = false;
	int counter=0;
	AbstractRoom * currentRoom;
	AbstractRoom *Start = BuildTheHouse(allRooms);
 	FillTheRooms(allRooms);
	std::string nothing;

	Holdall PlayerBag("Linen bag");
	PlayerBag.Capacity = 10;
 

  PathTest(Start, false, pathOne, 9);
	std::cout << "Hit <return> to continue: ";
	getline(std::cin, nothing);


	ActTest(Start, PlayerBag, ActOne, 31);
	// Only one action test can be run at a time for now,
	// since the game state changes and isn't reset.
	// Simply uncomment the test you want to run.
	//
	//  ActTest(Start, PlayerBag, ActFour, 10);
	//	ActTest(Start, &PlayerBag, ActTwo, 13);
	//	ActTest(Start, &PlayerBag, ActThree, 13);
	std::cout << std::endl << "Hit <return> to continue: ";
	getline(std::cin, nothing);

	UnitTests();
	std::cout << "Hit <return> to continue: ";
	getline(std::cin, nothing);


	FunctionPointerTest();

	for (int i=0; i < 8; i++)
	{
		delete(allRooms[i]);
	}
}
Пример #3
0
int main(int argc, char** argv)
{
	gn_argc = argc; gp_argv = argv;

	int iRc = 0;
	HMODULE hConEmu = NULL;
	wchar_t szErrInfo[200];
	DWORD dwErr;
	typedef int (__stdcall* ConsoleMain2_t)(BOOL abAlternative);
	ConsoleMain2_t lfConsoleMain2;

	#ifdef _DEBUG
	HMODULE hConEmuHk = GetModuleHandle(WIN3264TEST(L"ConEmuHk.dll",L"ConEmuHk64.dll"));
	_ASSERTE(hConEmuHk==NULL && "Hooks must not be loaded into ConEmuC[64].exe!");
	#endif

	#if defined(SHOW_STARTED_MSGBOX)
	if (!IsDebuggerPresent())
	{
		wchar_t szTitle[100]; _wsprintf(szTitle, SKIPLEN(countof(szTitle)) WIN3264TEST(L"ConEmuC",L"ConEmuC64") L" Loaded (PID=%i)", GetCurrentProcessId());
		const wchar_t* pszCmdLine = GetCommandLineW();
		MessageBox(NULL,pszCmdLine,szTitle,0);
	}
	#endif

	// Обязательно, иначе по CtrlC мы свалимся
	SetConsoleCtrlHandler((PHANDLER_ROUTINE)HandlerRoutine, true);

	#ifdef _DEBUG
	UnitTests();
	#endif

	// Some command we can process internally
	if (ProcessCommandLine(iRc, hConEmu))
	{
		// Done, exiting
		goto wrap;
	}

	// Otherwise - do the full cycle
	if (!hConEmu)
		hConEmu = LoadLibrary(WIN3264TEST(L"ConEmuCD.dll",L"ConEmuCD64.dll"));
	dwErr = GetLastError();

	if (!hConEmu)
	{
		_wsprintf(szErrInfo, SKIPLEN(countof(szErrInfo))
		           L"Can't load library \"%s\", ErrorCode=0x%08X\n",
		           WIN3264TEST(L"ConEmuCD.dll",L"ConEmuCD64.dll"),
		           dwErr);
		_wprintf(szErrInfo);
		_ASSERTE(FALSE && "LoadLibrary failed");
		iRc = CERR_CONEMUHK_NOTFOUND;
		goto wrap;
	}

	// Загрузить функи из ConEmuHk
	lfConsoleMain2 = (ConsoleMain2_t)GetProcAddress(hConEmu, "ConsoleMain2");
	gfHandlerRoutine = (PHANDLER_ROUTINE)GetProcAddress(hConEmu, "HandlerRoutine");

	if (!lfConsoleMain2 || !gfHandlerRoutine)
	{
		dwErr = GetLastError();
		_wsprintf(szErrInfo, SKIPLEN(countof(szErrInfo))
		           L"Procedure \"%s\"  not found in library \"%s\"",
		           lfConsoleMain2 ? L"HandlerRoutine" : L"ConsoleMain2",
		           WIN3264TEST(L"ConEmuCD.dll",L"ConEmuCD64.dll"));
		_wprintf(szErrInfo);
		_ASSERTE(FALSE && "GetProcAddress failed");
		FreeLibrary(hConEmu);
		iRc = CERR_CONSOLEMAIN_NOTFOUND;
		goto wrap;
	}

	// Main dll entry point for Server & ComSpec
	iRc = lfConsoleMain2(0/*WorkMode*/);
	// Exiting
	gfHandlerRoutine = NULL;
	//FreeLibrary(hConEmu); -- Shutdown Server/Comspec уже выполнен
wrap:
	//-- bottle neck: relatively long deinitialization
	ExitProcess(iRc);
	return iRc;
}
Пример #4
0
int main(int argc, char** argv)
{
	int iRc = 0;
	HMODULE hConEmu;
	char szErrInfo[512];
	DWORD dwErr, dwOut;
	typedef int (__stdcall* ConsoleMain2_t)(BOOL abAlternative);
	ConsoleMain2_t lfConsoleMain2;

	#if defined(SHOW_STARTED_MSGBOX)
	if (!IsDebuggerPresent())
	{
		wchar_t szTitle[100]; _wsprintf(szTitle, SKIPLEN(countof(szTitle)) WIN3264TEST(L"ConEmuC",L"ConEmuC64") L" Loaded (PID=%i)", GetCurrentProcessId());
		const wchar_t* pszCmdLine = GetCommandLineW();
		MessageBox(NULL,pszCmdLine,szTitle,0);
	}
	#endif

	// Обязательно, иначе по CtrlC мы свалимся
	SetConsoleCtrlHandler((PHANDLER_ROUTINE)HandlerRoutine, true);

	#ifdef _DEBUG
	UnitTests();
	#endif
	

	hConEmu = LoadLibrary(WIN3264TEST(L"ConEmuCD.dll",L"ConEmuCD64.dll"));
	dwErr = GetLastError();

	if (!hConEmu)
	{
		_wsprintfA(szErrInfo, SKIPLEN(countof(szErrInfo))
		           "Can't load library \"%s\", ErrorCode=0x%08X\n",
		           WIN3264TEST(L"ConEmuCD.dll",L"ConEmuCD64.dll"),
		           dwErr);
		WriteConsoleA(GetStdHandle(STD_ERROR_HANDLE), szErrInfo, lstrlenA(szErrInfo), &dwOut, NULL);
		return CERR_CONEMUHK_NOTFOUND;
	}

	// Загрузить функи из ConEmuHk
	lfConsoleMain2 = (ConsoleMain2_t)GetProcAddress(hConEmu, "ConsoleMain2");
	gfHandlerRoutine = (PHANDLER_ROUTINE)GetProcAddress(hConEmu, "HandlerRoutine");

	if (!lfConsoleMain2 || !gfHandlerRoutine)
	{
		dwErr = GetLastError();
		_wsprintfA(szErrInfo, SKIPLEN(countof(szErrInfo))
		           "Procedure \"%s\"  not found in library \"%s\"",
		           lfConsoleMain2 ? "HandlerRoutine" : "ConsoleMain2",
		           WIN3264TEST(L"ConEmuCD.dll",L"ConEmuCD64.dll"));
		WriteConsoleW(GetStdHandle(STD_ERROR_HANDLE), szErrInfo, lstrlenA(szErrInfo), &dwOut, NULL);
		FreeLibrary(hConEmu);
		return CERR_CONSOLEMAIN_NOTFOUND;
	}

	// Main dll entry point for Server & ComSpec
	iRc = lfConsoleMain2(0/*WorkMode*/);
	// Exiting
	gfHandlerRoutine = NULL;
	//FreeLibrary(hConEmu); -- Shutdown Server/Comspec уже выполнен
	ExitProcess(iRc);
	return iRc;
}