online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <cstdio> #include <cstdlib> #include <iostream> #include <iterator> #include <algorithm> #define SIZEOF_ARRAY(array) (sizeof(array) / sizeof(*array)) int main() { // Lambda expression auto compare = [](const void *lhs, const void *rhs) { int l = *static_cast<const int *>(lhs); int r = *static_cast<const int *>(rhs); return l - r; }; int data[] = { 3, 7, 5, 8, 7, 2, 9, 4, 1, 7, 6, 0 }; size_t size = SIZEOF_ARRAY(data); qsort(data, size, sizeof(int), compare); copy(std::begin(data), std::end(data), std::ostream_iterator<int>(std::cout, " ")); std::cout << '\n'; int val = 7; auto ans = static_cast<int *>(bsearch(&val, data, size, sizeof(int), compare)); if (ans != nullptr) std::cout << *ans << " found on index " << (ans - data) << '\n'; else std::cout << val << " not found\n"; }

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