online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <iostream> #include <iostream> using namespace std; const char empty = '.'; const char enemy = '#'; char map[10][10]; const int amountEnemies = 1; int tempPosX[(size_t)amountEnemies]; int tempPosY[(size_t)amountEnemies]; void initializeEnemies() { for (size_t y = 0; y < 10; y++) { for (size_t x = 0; x < 10; x++) { map[y][x] = empty; } } for(int i = 0; i < amountEnemies; i++) { tempPosX[i] = 5; tempPosY[i] = 5; map[tempPosX[i]][tempPosY[i]] = enemy; } } void updateEnemies() { for(int i = 0; i < amountEnemies; i++) { // Clears the current position. map[tempPosX[i]][tempPosY[i]] = empty; // Updates the enemy position. const int movement = rand() % 4; switch(movement) { case 0: tempPosX[i]++; break; case 1: tempPosX[i]--; break; case 2: tempPosY[i]++; break; case 3: tempPosY[i]--; break; } // Updates the enemy position. map[tempPosX[i]][tempPosY[i]] = enemy; } } void render() { for (size_t y = 0; y < 10; y++) { for (size_t x = 0; x < 10; x++) { std::cout<<map[y][x]; } std::cout<<std::endl; } } int main() { initializeEnemies(); render(); std::string n; while (n != "q") { std::cout << "enter q to quit, anything else to run a frame: "; std::cin>>n; updateEnemies(); render(); } 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