When i write this code i could not enter two lines as input where each line contains 3 to 5 words by gets() function:
int main()
{
int t;
cin>>t;
char nm1[50],nm2[50];
while(t--)
{
gets(nm1);
gets(nm2);
puts(nm1);
puts(nm2);
}
}
But when i add a gets() function earlier before while() function now i can enter two line of strings like this :
int t;
cin>>t;
char nm1[50],nm2[50];
gets(nm1); //using gets() function here//
while(t--)
{
gets(nm1);
gets(nm2);
puts(nm1);
puts(nm2);
}
So, what is the logic behind this?