phonebook is an array of pointers.
inside the handleMenu im allocating memory and pointing to structure where a first name is assigned to a struct that is pointed from phonebook[11].
as you can see in line 54, the name is assigned correctly and the program remembers it when exiting the handleMenu function, and i can access the details of the structure.
but after going down 1 line and ending the main while loop, the value suddenly changes.
what causes it and how to solve it? i want to remember the address to the structure but it seems that it wont save.
thanks in advance!
CodePudding user response:
check this first:while(option < 1 && 7 < option) this condition will never happen! be sure from this. when you trying to assign array of pointer type structs it should be allocated first .