This question I guess very very easy but I don't understand that it works with scanf and Code BLock Ide. But it doesnt work scanf_s and in Visual Studio. Why?
I get exception when I run this code part.
<pre>#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <string.h>
int main()
{
char city[10];
for (int i = 0; i < 2; i++)
{
printf("Please enter name of city:\n");
scanf_s("%s", city);
}
for (int i = 0; i < 2; i++)
{
printf("%s",city);
}
return 0;
}
What I have tried:
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <string.h>
int main()
{
char city[10];
for (int i = 0; i < 2; i++)
{
printf("Please enter name of city:\n");
scanf_s("%s", city);
}
for (int i = 0; i < 2; i++)
{
printf("%s",city);
}
return 0;
}