struct Point{
int x;
int y;
};
struct p = {0, 0};
printf("x: %d, y: %d", p.x, p.y);
struct Point{
int x;
int y;
} p = {0, 0};
printf("x: %d, y: %d", p.x, p.y);
struct Point newPoint(int x, int y){
struct Point p;
p.x = x;
p.y = y;
return p;
}
int pointCmp(struct Point a, struct Point b){
return a.x == b.x && a.y == a.y;
}
¿Comentarios?
int pointCmp(struct Point* a,struct Point* b){
return (*a).x == (*b).x && (*b).y == (*b).y;
}
int pointCmp(struct Point* a,struct Point* b){
return a->x == b->x && a->y == b->y;
}
struct Point{
int x;
int y;
};
struct Point p = {0, 0};
struct Point{
char x;
int y;
};
struct Point p = {0, 0};
sizeof struct Point -> 8 bytes
struct Node{
int index;
struct Node next;
};
struct Node{
int index;
struct Node* next;
};
unsigned int is_keyword : 1;
struct { unsigned int is_keyword : 1; unsigned int is_extern : 1; unsigned int is_static : 1;
}flags;
...
if(flags.is_static){
...
}
union tag{
int iVal;
float fVal;
double dVal;
} t;
t puede ser un int, un float o un double.
typedef char* String;
String s = "doh!";
struct Node{
char* value;
struct Node* next;
}
typedef char* String;
typedef struct Node* List;
struct Node{
String value; List next; };