0
Pointer to struct with pointer members
Hello! I'm having a problem with the code below. I want it to read the name and the price of the product and then print them out. The members of the struct have to be pointers and I need to have a pointer to a struct. Thank you! https://code.sololearn.com/ce47f3rbZPqq/?ref=app
3 Respuestas
+ 2
You need to allocate for each pointer separately. What you are doing now only allocates a struct with two pointers that point nowhere.
here is the fix:
https://code.sololearn.com/cpg40y479uef/?ref=app
0
Thank you very much O A T S! Why shouldn't I dereference the name?
0
By dereferencing it you pass the value of the first character in the string instead of a pointer to it.