online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <stdlib.h> #include <stdio.h> #include <string.h> struct tree { struct node *root; }; struct node { int val; struct node *left; struct node *right; }; struct tree * init () { struct tree *t = malloc (sizeof (struct tree)); t->root = NULL; return t; } void insert (struct tree *t, int val) { struct node *succ; struct node *new = malloc (sizeof (struct node)); new->val = val; new->left = NULL; new->right = NULL; succ = NULL; struct node *insertPlace = t->root; while (insertPlace != NULL) { succ = insertPlace; if (insertPlace->val < new->val) insertPlace = insertPlace->right; else insertPlace = insertPlace->left; } if (succ == NULL) t->root = new; else if (new->val < succ->val) insertPlace = succ->right; else insertPlace = succ->left; } void inorderWalk (struct node *p) { if (p != NULL) { if (p->left != NULL) inorderWalk (p->left); printf ("%d ", p->val); if (p->right != NULL) inorderWalk (p->right); } } void print (struct tree *t) { struct node *p; p = t->root; inorderWalk (p); } int main () { struct tree *t = init (); insert (t, 5); insert (t, 15); insert (t, 20); insert (t, 1); insert (t, 2); insert (t, 4); insert (t, 10); print (t); 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