online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <array> #include <iostream> #include <vector> // using namespace std; <== really dont! C++ Weekly - Ep 305 - Stop Using `using namespace` https://www.youtube.com/watch?v=MZqjl9HEPZ8&t=112s // I almost never use pair, it usually // leads to hard to read code. So define my own datatype struct my_data_t { std::uint8_t index; std::uint8_t value; }; constexpr std::uint8_t Set{ 0x00U }; constexpr std::uint8_t Unset{ 0x01U }; constexpr std::uint8_t First{ 0x01U }; constexpr std::uint8_t Second{ 0x03U }; constexpr std::uint8_t Third{ 0x05U }; constexpr std::uint8_t Fourth{ 0x1DU }; constexpr std::uint8_t Fifth{ 0x27U }; constexpr std::array<my_data_t, 5> buffer{ { {First,Set}, {Second,Unset}, {Third,Unset}, {Fourth,Unset}, {Fifth,Unset} }}; int main() { std::vector<std::uint8_t> reply; reply.reserve(buffer.size()*2ul + 1ul); reply.push_back(static_cast<std::uint8_t>(buffer.size())); for (const auto& [index, value] : buffer) { reply.push_back(index); reply.push_back(value); } for (const auto value : reply) { // cast to (unsinged) int type to get "readable" output. Otherwise we just print "control characters" std::cout << static_cast<std::uint16_t>(value) << " "; } return 0; }

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