ho:l'inizializzazione diretta di una struttura in C
struct date
{
int day;
int month;
int year;
};
struct person {
char name[25];
struct date birthday;
};
struct date d = { 1, 1, 1990 };
inizializzazione con
struct person p1 = { "John Doe", { 1, 1, 1990 }};
opere.
Ma se provo
struct person p2 = { "Jane Doe", d};
ottengo un errore del tipo:
"data non può essere convertito in int".
Cosa c'è di sbagliato? d è una struct date e il secondo parametro dovrebbe essere anche una struct date. Quindi dovrebbe funzionare. Grazie e saluti
possibile duplicato di [Inizializzazione struttura C con variabile] (http://stackoverflow.com/questions/7700878/c-structure-initialization-with-variable) – Kishore