Hello everyone
In the following code gets () function does not work and the program comes out without executing that.
OF course if I write the gets () function in the first line
It works. Why? Something wrongs with buffer
Code:
#include<stdint.h>
#include<string.h>
int main(void){
char names[4][10];
char city[10];
char revTemp;
int i=0;
puts("Enter four names :");
for(i=0;i<4;i++)
scanf(" %s" , names[i]);
printf("The orginal names are : %s %s\n" , &names[1][0], &names[2][0]);//before exchane names
for(i=0;i<=9;i++){
revTemp=names[1][i];
names[1][i]=names[2][i];
names[2][i]=revTemp;
}
printf("The names after the exchange :%s %s \n" , &names[1][0] , &names[2][0]);//after exchange the names
puts("Enter the city");
gets(city);//This line doesn't execute ERRORE
return 0;
}
Thank you