#include <stdio.h>
#include <string.h>
struct Ball {
char color[10];
double radius;
};
struct Car {
struct Ball ball;
int count;
};
struct Fruit {
int apple;
} fruit;
//typedef like alise
typedef int foo;
typedef struct Car car2;
enum color {
red, green, yellow
};
enum color get_color(){
return green;
}
union int_or_float {
int int_member;
float float_member;
};
struct Student {
char name[20];
int roll;
};
main(){
struct Ball ball;
strcpy(ball.color, "green");
ball.radius = 3.14159;
printf("%s %.5f\n", ball.color, ball.radius);
struct Car car;
strcpy(car.ball.color, "red");
car.count = 10;
printf("%s %.5f\n", car.ball.color, car.count);
struct Ball ball2 = {"yellow", 1.234};
printf("%s %.5f\n", ball2.color, ball2.radius);
printf("%d\n", ++fruit.apple);
foo f = 10;
printf("%d\n", f);
car2 car3;
strcpy(car3.ball.color, "black");
car3.count = 5;
printf("%s %d\n", car3.ball.color, car3.count);
enum color mycolor;
mycolor = get_color();
if(mycolor == green)
printf("match color green.\n");
union int_or_float myuni1, myuni2;
myuni2.float_member = 1.234;
struct Student *student, stu;
student=&stu;
strcpy(student->name, "Huang");
student->roll = 2;
printf("%s %d\n", student->name, student->roll);
printf("%s\n", (*student).name);
}