|
|
|
|
Strumenti |
20-04-2020, 09:29 | #1 |
Junior Member
Iscritto dal: Jan 2020
Messaggi: 17
|
Semplice domanda sulle strutture
salve,
correggetemi se sbaglio .. se uso il: Codice:
typedef struct mystruct * st_1; chiedo perchè sto avendo difficoltà con alcuni esercizi che mi vanno in core dump penso possibile sbaglio nell'allocazione di st_1, in questo modo fatta: Codice:
st_1=malloc(sizeof(mystruct)*n); |
20-04-2020, 10:36 | #2 |
Senior Member
Iscritto dal: Apr 2001
Città: Milano
Messaggi: 3594
|
Codice:
struct mystruct { char nome[20]; char cognome[20]; char cell[20]; }; typedef struct mystruct pippo; pippo *st_1; st_1 = (struct mystruct *)malloc(sizeof(mystruct) * 10); free(st_1); Codice:
struct mystruct { char nome[20]; char cognome[20]; char cell[20]; }; struct mystruct *st_1; st_1 = (struct mystruct *)malloc(sizeof(mystruct) * 10); free(st_1); |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 23:55.