Using Pointer in Struct

#include <iostream>
using namespace std;
struct data{
       int x;
       int y;
       char c;
};
int main()
{
    data se;
    data *p;
    p=&se;
    p->x=5;
    p->y=7;
    p->c='z';
    cout<<p->x*p->y<<endl;
    cout<<p->c<<endl;
    system("pause");
    return 0;
}
    


The output is given below:
35
z

0 comments:

Post a Comment