인프런 커뮤니티 질문&답변
5.4 3분
작성
·
253
0
아래코드는 강의 속 예시와 다르게 원가가 증가하는 것을 출력하지못하고 0.000 으로 뜨고
while문 안 printf 에서
Severity Code Description Project File Line Suppression State
Warning C4477 'printf' : format string '%lf' requires an argument of type 'double', but variadic argument 1 has type 'double *'
위와 같은 두가지 주의의 의미가 무슨뜻이고 어떻게 해야 예시와 같이 출력되나요
#include <stdio.h>
int main(void)
{
double seed_money = 0;
double target_money = 0;
double annual_interest = 0;
int year = 0;
printf("Input seed money : ");
scanf("%lf", &seed_money);
printf("Input target money : ");
scanf("%lf", &target_money);
printf("Input annual interest (%%) : ");
scanf("%lf", &annual_interest);
while (seed_money < target_money)
{
year++;
seed_money = seed_money * (1 + annual_interest / 100);
printf("%lf\n", &seed_money);
}
printf("It takes %d years" , year);
return 0;
}
답변 1
0
안녕하세요? 지금 작성하신 이 두 문장에서 하나는 사용이 잘못됐습니다. 직접 찾아내실 수 있었으면 좋겠네요.
printf("%lf\n", &seed_money);
printf("It takes %d years" , year);




