I would just like to ask, is it possible to allocate to the same variableCode:int foodcalorie (int *num,struct recipe **foodcal) { char ans='Y'; system("cls"); while(ans=='Y' && *foodcal!=NULL) { system("cls"); if((*foodcal=malloc(sizeof(struct recipe)*(*num)))!=NULL){ printf("Input name of food\n"); scanf(" %s",(*foodcal+(*num))->name); printf("Input calorie count\n"); scanf(" %d",&(*foodcal+(*num))->calorie); printf("Input specific amount with unit\n"); scanf(" %f %s",&(*foodcal+(*num))->quantity,(*foodcal+(*num))->unit); printf("Do you wish to add again? [Y]es or [N]o\n"); scanf(" %c",&ans); if(ans=='Y') *num+=1; } } return 1; }
again after incrementing the multiplier for "malloc"? "realloc" also can't work >_< Checked where the error was and it was after looping once then gives me the "Access Violation Segmentation Fault. Thank you very much