online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> #include <iomanip> #include <sstream> #include <string> #include <cwchar> static const unsigned int CP_ACP = 0; int WideCharToMultiByte( unsigned int CodePage, unsigned long dwFlags, const wchar_t* lpWideCharStr, int cchWideChar, char* lpMultiByteStr, int cbMultiByte, char* lpDefaultChar, bool* lpUsedDefaultChar ) { if (cchWideChar == -1) cchWideChar = static_cast<int>(std::wcslen(lpWideCharStr) + 1); if (cbMultiByte == 0) return cchWideChar + 1; if (cbMultiByte < cchWideChar) cchWideChar = cbMultiByte; std::copy(lpWideCharStr, lpWideCharStr + cchWideChar, lpMultiByteStr); return cchWideChar; } void OutputDebugStringA(const char *str) { std::cout << str << std::endl; } std::ostream& operator<<(std::ostream &os, const std::wstring &wstr) { int len = WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), wstr.size(), nullptr, 0, nullptr, nullptr); if (len > 0) { std::string str; str.resize(len); WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), wstr.size(), str.data(), len, nullptr, nullptr); os << str; } return os; } template <typename Arg, typename... Args> void doPrint(Arg&& arg, Args&&... args) { std::stringstream out; out << std::forward<Arg>(arg); using expander = int[]; (void)expander { 0, (void(out << std::left << std::setw(20) << std::forward<Args>(args)), 0)... }; OutputDebugStringA(out.str().c_str()); } int main() { std::wstring color = L"blue"; doPrint("color: ", color); }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue