I have a struct
Code:
struct animation
{
char *name;
}
I am entering the animation names manually, e.g. "standstill"
I want to allocate memory depending on the size of the constant string so my function is:
Code:
char* dynamic_str_pointer(const char *my_string)
{
return (char *)malloc(sizeof(char) * (strlen(my_string)+1));
}
I am calling it like this:
Code:
animation a;
a.name=dynamic_str_pointer("standstill");
but the compiler doesnt like it, it just says there are multiple definitions of the function (but there are not)