print as hex
1 2 const int val = 28; 3 cout.setf(ios_base::hex, ios_base:showbase, ios_base::basefield); 4 cout << val;
ref :stroustroup, c++ programming language, pg. 627
12946 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
1 2 const int val = 28; 3 cout.setf(ios_base::hex, ios_base:showbase, ios_base::basefield); 4 cout << val;
1 2 #include <shlwapi.h> 3 4 BOOL CMyApp::InitInstance() 5 { 6 // ... 7 8 TCHAR szIniPath[MAX_PATH]; 9 VERIFY(::GetModuleFileName(::AfxGetInstanceHandle(), szIniPath, MAX_PATH) != 0); 10 VERIFY(::PathRenameExtension(szIniPath, _T(".ini")) != FALSE); 11 ::free(static_cast<LPVOID>(const_cast<LPTSTR>(m_pszProfileName))); 12 m_pszProfileName = ::_tcsdup(szIniPath); 13 14 // ... 15 16 return TRUE; 17 }
1 2 CSPyInterpreter* it = CSPyInterpreter::NewInterpreterL(); 3 CleanupStack::PushL(it); 4 PyEval_RestoreThread(PYTHON_TLS->thread_state); 5 6 PyRun_SimpleString("open(r'c:\\foo.txt', 'w').write('hello')\n"); 7 8 PyEval_SaveThread(); 9 CleanupStack::PopAndDestroy(it);
1 template <class T> T 2 fromString(const string &s) { 3 T t; 4 istringstream iss(s); 5 iss >> t; 6 return t; 7 }
1 double d = fromString<double>("10.2")