I am just trying to understand why i get a segmentation fault when I use char *name as the member of the struct name... as apposed to char name[30] as the member, which works properly. thankyou.
struct name
{
char *name1; // if i make this char name[30]; it works properly
};
void name_prompt(struct name *ptr)
{
printf("name: ");
scanf("%s", ptr->name1);
}
int main ()
{
struct name dylan;
struct name *ptr = &dylan;
name_prompt(ptr);
printf("%s", dylan.name1);
}