I have this class for save receipt :
class Recept {
int Ingr_size;
char *Name;
char *Type;
char *Recipe;
struct Ingridient {
char *aName;
float Mas;
} *List_ingr;
when i trying to save ingredient name or mass by using this function:
void Recept::setIngr(const char * p, float mass) {
struct Ingridient * temp = new struct Ingridient[Ingr_size + 1];
if (Ingr_size) {
for (int i = 0; i < Ingr_size; i++)
temp[i] = List_ingr[i];
delete List_ingr;
List_ingr = temp;
}
List_ingr[Ingr_size].aName = new char[strlen(p) + 1];
strcpy(List_ingr[Ingr_size].aName, p);
List_ingr[Ingr_size].Mas = mass;
}
I get an error that "Unable to reach aName
memory" & "Unable to reach Mas
memory".
I can't find the problem where or why.
Thank you.