online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <iostream> #include <cstdlib> using namespace std; class Item { public: Item():val{0}, next{nullptr} {} int val; Item *next; }; class Avlist { public: Avlist():head{nullptr}, cnt{0} {} void add_space(int n) { Item *start = (Item *)malloc(n*sizeof(Item)); for (int i = 0; i < n; ++i) { (start + i)->next = head; (start + i)->val = cnt; ++cnt; head = (start + i); } } void printlist() const { for (Item *p = head; p; p = p->next) { cout << p->val << " "; } cout << endl; } Item *head; int cnt; }; int main() { Avlist l; l.add_space(5); l.printlist(); l.add_space(10); l.printlist(); 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