I have a function which I pass a character pointer to, like:
funtion_name (char* string){
...
}
I want to copy the string to a temporary string variable, then copy that into a struct. This is what I have done thus far:
char* namecpy = malloc(strlen(string+1));
strcpy(namecpy, string);
strcpy(ptr->name, namecpy);
This is giving me a segmentation fault when I call the function. I think it's because I'm not allowed to directly copy into the struct variable... but how else would I have to copy it?