I am currently learning dynamic memory allocation and came to find out that I have to store a string into a character pointer .
I have a structure Character.
struct Character{
char *name;
name = (char*) malloc(40*sizeof(char));
int Level;
long XP;
struct Inventory inventory;
};
The scope of the above structure is global.
I also have a function which takes pointer to structure and takes the input of the structure member.
void createCharacter(struct Character* b){
printf("Enter Name:");
scanf("%s",b->(*name));
printf("Enter Level:");
scanf("%d",&(b->Level));
printf("Enter XP:");
scanf("%ld",&b->XP);
}
My question is how to store the value given by user to that pointer.