online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <stdio.h> #include <stdlib.h> #define WORLD_WIDTH 40 #define WORLD_HEIGHT 20 float earth_height; float object_height[WORLD_WIDTH]; int steps; void display(void) { printf("Step: %d\n", steps); for (int y=WORLD_HEIGHT; y>=0; y--) { printf("#"); for (int x=0; x<WORLD_WIDTH; x++) if (y == earth_height) printf("#"); else if ((int)object_height[x] == y) printf("*"); else printf(" "); printf("\n"); } printf("\n"); } void fall_gravity(void) { for (int i=0; i<WORLD_WIDTH; i++) object_height[i] -= 1; } void fall_flat(void) { earth_height++; } // Simple detection if an object and the ground have collided. void detect_collisions(void) { for (int i=0; i<WORLD_WIDTH; i++) { if (object_height[i] == earth_height) object_height[i] += 1; } } void main(void) { for (int m=0; m<2; m++) { srand(123); // Same seed for every run. steps = 0; for (int i=0; i<WORLD_WIDTH; i++) object_height[i] = rand()%WORLD_HEIGHT+1; for (int i=1; i<WORLD_HEIGHT; i++) { steps++; if (m == 0) fall_gravity(); else fall_flat(); detect_collisions(); display(); } } }

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