#include <stdio.h>
int main() {
char prompt1[] = "Enter your first name:", prompt2[] = "Enter your last name:";
char gratis[] = "Thanks!", first[], last[]; //empty declaration of string varible
printf(prompt1);
scanf("%s", &first);
printf(prompt2);
scanf("%s", &last);
printf("%s\n", gratis);
printf("Your name is %s %s\n", first, last);
return (0);
}
Why can't the string variable be declared without specifying the size of the char array? The same code works fine when the size of the array is mentioned.