I'm trying to dynamically allocate memory to a char pointer using malloc()
but not sure what I'm missing here.
void item(struct product *pr, const char *title, double price)
{
title = malloc((strlen(title)+1) * sizeof(const char));
}
I added the +1 for the /0
character, not sure if needed, but didn't work without it either. I assume I don't need to allocate memory for the structs or double.