online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
/* triangle.c */ #include <cstdlib> #include <cstdint> #include <curses.h> //#include "getrandom_int.h" funny guys own rand, lets use crappy C rand from stdlib for now /* The state word must be initialized to non-zero */ uint32_t xorshift32(uint32_t & state) { /* Algorithm "xor" from p. 4 of Marsaglia, "Xorshift RNGs" */ uint32_t x = state; x ^= x << 13; x ^= x >> 17; x ^= x << 5; return state = x; } int getrandom_int() { //return rand() & 0x7FFFFFFF; static uint32_t state = 123; xorshift32( state ); return state & 0x7FFFFFFF; } #define ITERMAX 10000 int main(void) { long iter; int yi, xi; int y[3], x[3]; int index; int maxlines, maxcols; /* initialize curses */ initscr(); cbreak(); noecho(); clear(); /* initialize triangle */ maxlines = LINES - 1; maxcols = COLS - 1; y[0] = 0; x[0] = 0; y[1] = maxlines; x[1] = maxcols / 2; y[2] = 0; x[2] = maxcols; mvaddch(y[0], x[0], '0'); mvaddch(y[1], x[1], '1'); mvaddch(y[2], x[2], '2'); /* initialize yi,xi with random values */ yi = getrandom_int() % maxlines; xi = getrandom_int() % maxcols; mvaddch(yi, xi, '.'); /* iterate the triangle */ for (iter = 0; iter < ITERMAX; iter++) { index = getrandom_int() % 3; yi = (yi + y[index]) / 2; xi = (xi + x[index]) / 2; mvaddch(yi, xi, '*'); refresh(); } /* done */ mvaddstr(maxlines, 0, "Press any key to quit"); refresh(); getch(); endwin(); exit(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