Strange behavior of Strings
Hi All,
The following code line behaves strange...Could anyone of you help in understanding this out....
Code:
char a[10];
printf("\nEnter a string:");
scanf("%s ",a);
printf("\nAccepted String is :%s",a);
I gave an extra space " " in the scanf statment after "%s".
The output behaves as follows:
Enter a String:abcdef
a
Accepted String is :abcdef
Although I press enter key after entering the string when prompted...it is waiting for me to give one more character. After entering an extra character in 2nd line, then the output is being displayed....
Kindly help me out...
Best Regards,
Shyamlal SVS.