online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <iostream> using namespace std; void PushStack(int *argStack, int argNew) { int arrSize = sizeof(*argStack)+1; //cout << "(PushStack) arrSize=" << to_string( arrSize ) << ", *argStack=" << to_string( sizeof(*argStack) ) << endl; if(argStack[arrSize-1]!=0) { cout << "(PushStack) STACK IS ALREADY FULL (argNew=" << to_string( argNew ) << ")" << endl; return; } for(int arrIdx=0; arrIdx<arrSize; arrIdx++) { if(argStack[arrIdx]>0) { continue;/*해당 층은 이미 투숙객이 있으니 윗층으로*/ } argStack[arrIdx]=argNew; cout << "(PushStack) new TOP [" << to_string( arrIdx ) << "]=" << to_string( argStack[arrIdx] ) << endl; break; } } int PopStack(int *argStack) { int result = 0; int arrSize = sizeof(*argStack)+1; //cout << "(PopStack) arrSize=" << to_string( arrSize ) << ", *argStack=" << to_string( sizeof(*argStack) ) << endl; if(argStack[0]==0) { cout << "(PopStack) STACK IS EMPTY!!!" << endl; return argStack[0]; } for(int arrIdx=arrSize-1; arrIdx>=0; arrIdx--) { if(argStack[arrIdx]==0) { continue;/*해당 층은 이미 빈방이다.*/ } result = argStack[arrIdx]; argStack[arrIdx]=0; arrIdx = arrIdx-1; if(arrIdx<=0){ arrIdx=0; } cout << "(PopStack) new TOP [" << to_string( arrIdx ) << "]=" << to_string( argStack[arrIdx] ) << endl; break; } return result; } int main() { int stackI[5] = {0, 0, 0, 0, 0}; cout << "stackI SIZE=" << to_string(sizeof(stackI)) << endl; cout << "*stackI SIZE=" << to_string(sizeof(*stackI)) << endl; cout << "---------------------" << endl; PushStack(stackI, 2023); PushStack(stackI, 9); PushStack(stackI, 23); PushStack(stackI, 14); PushStack(stackI, 11); PushStack(stackI, 22); PushStack(stackI, 33); PopStack(stackI); PopStack(stackI); PushStack(stackI, 44); PushStack(stackI, 55); PopStack(stackI); PopStack(stackI); PopStack(stackI); PopStack(stackI); PopStack(stackI); 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