Code:
void new_friend(){
char *name;
char *phone;
char *email;
printf("\n------New friend info------\n");
printf("Name: ");
scanf("%s", name);
printf("Phone-No: ");
scanf("%s", phone);
printf("e-Mail: ");
scanf("%s", email);
printf("KALPA");
write_to_file(name, phone, email);
}
this code block results in a segmentation error and it does not prompt the user for phone no also. It prompts only for the name and email.
Why is this?
But if character arrays are used instead of character pointers, it works. Why is this?