Hi
I'm writing a pretty simple C program and I have to read in information from the user at the command line. I'm having problems getting input that has spaces. I have this code i:
CODE
char *query = "";
char *email = "";
char fname[30] = "";
char lname[30] = "";
char name[] = "";
char *street = "";
char *city = "";
char *state = "";
char *zip = "";
char *phone = "";
printf("***************NEW USER SIGNUP***************");
printf("\n\tEnter email address: ");
scanf ("%s", &email);
printf("\n\tEnter first name: ");
scanf ("%s", &fname);
printf("\n\tEnter last name: ");
fgets (lname, 50, stdin);
// scanf ("%s", &lname);
// strcat(name, fname);
// strcat(name, lname);
printf("\n\tEnter street: ");
fgets (street, 50, stdin);
printf("\n\tEnter city: ");
scanf ("%s", &city);
printf("\n\tEnter state: ");
scanf ("%s", &state);
printf("\n\tEnter zip code: ");
scanf ("%s", &zip);
I've tried the commented out lines, but it gives me a seg fault and the way I have it now, it skips the input part of 'last name' and gets a seg fault on 'street' even when it's a single line input.