Struct
A struct is a data structure composed of simpler data types.
There is no methods or inheritance.
struct point {
int x;
int y;
}
main(){
struct point p1;
// get memory allocated for two int
p1.x = 5;
p2.y = 10;
}
void printPoint(struct point p){
printf("(%d,%d)", p.x, p.y);
}
struct point *p;
p = malloc(sizeof(struct point));
printf("x is %d\n",(*p).x);
printf("x is %d\n", p->x);
Published on
October 16, 2015