online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> struct Mystruct { int a, b; }; Mystruct *sum_struct(const Mystruct *x, const Mystruct *y) { Mystruct *ret= new Mystruct(); //note the use of keyword new here. Also note that ret is a pointer now ret->a = x->a + y->a; //note the use of ret->a instead of ret.a since ret is a pointer now ret->b = x->b + y->b; //note the use of ret->a instead of ret.a since ret is a pointer now std::cout << ret->a << "--" << ret->b << "--\n"; //note the use of ret->a instead of ret.a since ret is a pointer now. Show 6--7-- return ret; } int main() { Mystruct o, p, *q; p.a = 1; p.b = 2; o.a = 5; o.b = 5; q = sum_struct(&o, &p); std::cout << q->a << "--" << q->b << "--\n"; // shows 6--7-- //use delete delete q; }

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