Provare a riprendere il vecchio linguaggio C. Attualmente sul struct e ottenere questo errore:C: la variabile ha l'inizializzatore ma il tipo è incompleto
"variable 'item1' has initializer but incomplete type"
Ecco il mio codice:
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);
}
ho indovinato forse il defintion struct era in una posizione sbagliata così ho spostato al all'inizio del file e ricompilato, ma sto ancora ricevendo lo stesso errore. Dov'è il mio errore?