When I run this program, it allows me to enter the first name, then it gives me a segmentation fault.
I dont know why this happens or how to get rid of it.
#include <stdio.h>
int main (void)
{
FILE *fp;
fp = fopen("list.txt","a+");
if (fp == NULL){
printf("File list.txt could not be opened.");
}
for(int i=0;i<3;i++){
char *name;
char *str;
char *sta;
printf("Please enter your name: ");
scanf("%s",name);
printf("Please enter your street: ");
scanf("%s",str);
printf("Please enter your state: ");
scanf("%s",sta);
fprintf(fp,"%s,%s,%s\n",name,str,sta);
}
fclose(fp);
}