Salve a tutti, premetto che non sono un esperto di C ma ho iniziato da poco. Ad ogni modo ho un problema con l'acquisizione da input di variabili numeriche che fanno riferimento all'enum precedentemente dichiarato, ma per essere più esauriente allego il codice direttamente interessato dall'errore.
L'errore che mi da è:codice:#include <stdio.h> #include <stdlib.h> typedef enum anony { crocchette = 0, scatolette = 1, tonno = 2 } cibo; typedef struct rec { int codice; int anni; float peso; //in kg cibo pasto; } gatto; ..................... main ..................... gatto* inp_gatti(int n) { gatto* a = malloc(n * sizeof(gatto)); for (int i = 0; i < n; ++i) { scanf("%d", &a[i].codice); scanf("%d", &a[i].anni); scanf("%f", &a[i].peso); scanf("%d", &a[i].pasto); } return a; }
"warning: format ‘%d’ expects argument of type ‘int *’, but argument 2 has type ‘cibo * {aka enum anony *}’ [-Wformat=]
scanf("%d", &a.pasto);"
Grazie in anticipo![]()

Rispondi quotando