online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <stdio.h> #include <stdlib.h> #define SIZEOF_ARRAY(array) (sizeof(array) / sizeof(*array)) int compare(const void *lhs, const void *rhs) { int l = *(const int *) lhs; int r = *(const int *) rhs; if (l < r) return -1; if (l > r) return 1; return 0; } int main() { int data[] = { 3, 7, 5, 8, 7, 2, 9, 4, 1, 6, 7, 0 }; size_t size = SIZEOF_ARRAY(data); qsort(data, size, sizeof(int), compare); for (size_t i = 0; i < size; ++i) { printf("%d ", data[i]); } printf("\n"); int val = 7; int *ans = (int *) bsearch(&val, data, size, sizeof(int), compare); if (ans != NULL) printf ("%d found on index %td\n", *ans, (ans - data)); else printf ("%d not found\n", val); 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