#include <stdio.h>
struct fruit1
{
double price_per_pound, weight;
};
void function(struct fruit1 call);
void main()
{
static struct fruit1 apple1={0};
static struct fruit1 orange1={0};
static struct fruit1 potato1={0};
static struct fruit1 onion1={0};
function(apple1);
}
void function(struct fruit1 n){
printf("Enter an %s price_per_pound: ",n);
scanf_s("%lf",&n.price_per_pound);
printf("Enter the weight of %ss in pounds: ",n);
scanf_s("%lf",&n.weight);
printf("The cost of %s is %lf ",n,n.price_per_pound*n.weight);
}
출력부분 %s,n cost 좀 가르쳐주세요 제대로 된 값이 안나옴 ㅠㅠ
대체 왜 static으로 선언해준거임 그리고 초기화할때도 {0}이 아니라 {0,}이 맞지않나
그리고 대체 무슨문자열을 출력하고 싶길레 구조체를 문자열로 출력하려고 하는거임 걍 코드가 개미쳣음