Hi All,
I am facing the scanf() function problem, below given is a small code snippet where am facing the problem.
int main()
{
char str1[100];
char str2[100];
printf("Enter 1st string\n");
scanf("%[^\n]s",&str1);
printf("Enter 2nd string\n");
scanf("%[^\n]s",&str2);
printf("1st string is %s\n", str1);
printf("2nd string is %s\n", str2);
return 0;
}
The first string is taking the input properly along with white spaces. But the second string is not at all taking anything. It is showing blank, when i print the second string. I am not understanding how to solve this problem, please help me out from this. I suspect it will be something regarding the use of fflush to clear to user input given for first string.
Thanks in advance
Regards,
Raghavendra. H. R