This is part of an assignment that I'm supposed to submit, this program is supposed to take 2 inputs, a name containing 4 letters and a city containing 5 letters then sub them in that sentence. The problem is that the first word is not being output properly, like if I type john all I get is 'r' instead of the word. I'm new to this and there might be other mistakes, but I wanna fix this one. Help greatly appreciated. :l
#include <stdio.h>
int main(int argc, char **argv)
{
char name1[4];
char city1[5];
printf("\nEnter four letter name:\n");
scanf("%s", name1);
printf("\nEnter five letter city:\n");
scanf("%s", city1);
printf("%s was afraid of the airplane, he walked from %s to Romaine.", name1, city1);
return 0;
}
When I put John and Denver it output "r was afraid of the airplane he walked from Denver to Romaine"