Most likely, the space you have allocated to
city
is not big enough to store what you are entering: 10 characters is not a lot, and you are probably exceeding it.
Try this:
int main()
{
char city[100];
for (int i = 0; i < 2; i++)
{
printf("Please enter name of city:\n");
scanf_s("%s", city, 10);
}
for (int i = 0; i < 2; i++)
{
printf("%s", city);
}
return 0;
}
It still won't do what you want it to because it will print the last name twice, but it shouldn't crash.