Sunday, January 2, 2011

Mac OSでC言語を使用する場合のDouble型について

Mac OSでC言語を使用する場合、結構忘れるのでメモを残しておく。
Double型の変数を使用する場合、『%lf』を用いて
値を取得する。

/* "struct Car" Declaration */
struct Car {
int num;
double gas;
};

int main(void) {

struct Car car1;

car1.num = 1234;
car1.gas = 25.5;

printf("the car number is %d.: the amount of gas is %lf.\n", car1.num, car1.gas);

return 0;
}



No comments:

Post a Comment