void main(void){
typedef union{
short individual; // 개인
float won; // 원화
float ounce; // 온스
} amount;
amount orangeAmt = {.ounce = 16};
orangeAmt.individual = 4;
printf("Orange Juice Amount: %.2f : Size: %ld\n\n", orangeAmt.ounce, sizeof(orangeAmt.ounce));
printf("Number of Oranges: %f : Size: %ld\n\n", orangeAmt.individual, sizeof(orangeAmt.individual));
orangeAmt.won = 1.5;
printf("Orange Juice Amount: %.2f : Size: %ld\n\n", orangeAmt.won, sizeof(orangeAmt.won));
typedef struct{
char *brand;
amount theAmount;
} orangeProduct;
orangeProduct productOrdered = {"Chiquita", .theAmount.ounce = 16};
printf("You bought %2.f ounces of %s oranges\n\n", productOrdered.theAmount.ounce, productOrdered.brand);
typedef enum{ INDIV, OUNCE, OWN } quantity;
quantity quantityType = INDIV; // OUNCE Change
orangeAmt.individual = 4;
if(quantityType == INDIV){
printf("You bought %d oranges\n\n", orangeAmt.individual);
} else if(quantityType == OUNCE){
printf("You bought %.2f ounces of oranges\n\n", orangeAmt.ounce);
}
}
댓글 없음:
댓글 쓰기