Complex Structures in C
// Online C compiler to run C program online
#include <stdio.h>
struct add{
int no;
int areacode;
}typedef a;
struct New{
int val;
// struct add ss;
struct add ss[2];
};
// void dis(a obj){
void dis(a *obj){
// printf("%d\n%.2f\n",obj.no,obj.areacode);
// printf("%d\n%.2f\n",obj->no,obj->areacode);
printf("%d\n%d\n",*(obj),*(obj+1));
}
struct add ret(struct add a){
printf("Returned!!\n");
return a;
}
int main() {
// Write C code here
// printf("Start small. Ship something.");
struct New n={
12,
{
{13,12},
{14,23}
}
};
// n.val=12;
// n.ss.no=13;
// n.ss.areacode=12.34;
// printf("%d\n%d\n%.2f\n",n.val,n.ss.no,n.ss.areacode);
printf("%d\n%d\n%df\n",n.val,n.ss[1].no,n.ss[1].areacode);
a o;
o.no=34;
o.areacode=12;
dis(&o);
struct add sf=ret(o);
return 0;
}
Comments
Post a Comment