오래된 C 언어를 머리에 쓰려고합니다. 현재 구조체에이 오류가 :C : 변수에 초기화가 있지만 불완전한 형식이 있습니다.
"variable 'item1' has initializer but incomplete type"
여기 내 코드입니다 : 나는 아마도 구조체 (고화질)가 잘못된 위치에 짐작
typedef struct
{
int id;
char name[20];
float rate;
int quantity;
} item;
void structsTest(void);
int main()
{
structsTest();
system("PAUSE");
return 0;
}
void structsTest(void)
{
struct item item1 = { 1, "Item 1", 345.99, 3 };
struct item item2 = { 2, "Item 2", 35.99, 12 };
struct item item3 = { 3, "Item 3", 5.99, 7 };
float total = (item1.quantity * item1.rate) + (item2.quantity * item2.rate) + (item3.quantity * item3.rate);
printf("%f", total);
}
그래서 난 파일과 컴파일의 상단으로 이동 하지만 여전히 같은 오류가 발생합니다. 내 실수는 어디 갔어?