#include <iostream>
using namespace std;
struct rectangle
{
int length;
int breadth;
};
struct rectangle *fun()
{
struct rectangle *p;
p = new rectangle;
//p= (struct rectangle *)malloc(sizeof(struct rectangle));
p->length = 15;
p->breadth = 7;
return p;
}
int main()
{
struct rectangle *ptr = fun();
cout << "length : "<<ptr->length<<endl<<"breadth : "<< ptr->breadth<<endl;
return 0;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter