2
I have a struct
who owns nome
and horário
for appointments.
typedef Struct{
char nome[20];
char data[20];
}Dados;
I make the statement:
Dados *dados_cliente[quantidade];
I make the allocation (whenever I start a new marking to not allocate everything):
dados_cliente[i]=malloc(sizeof(Dados));
Now I’m working for the user to edit the markup, I could use an auxiliary structure but I preferred to do it this way:
// SÓ VOU COLOCAR CASO ELE QUEIRA MUDAR O NOME PARA NÃO FICAR ENORME
Case 1:
free(dados_clientes[i]->nome);
printf("DIGITE O NOVO NOME:\n);
fflush(stdin);
scanf("%[^\n]",dados_clientes[i]->nome);
Now my question, when I used the free()
just in the name, do I need to allocate again? Or I should forget all this and use an auxiliary structure, and/or suggestions to solve it, if possible.
Are you mistaken in what the
malloc
andfree
mean. I advise you to start reviewing around, learning well what each one does and what the implications.– Isac