Just a prediction, somebody will correct me if I am wrong!
Here is a new code
Code:
#include <stdio.h>
int main()
{
char a[10];
char b[10];
printf("\nEnter a string:");
scanf(" %s %s",a,b);
printf("\nAccepted String is :%s %s",a,b);
return 0;
}
There are two white soaces before and after the first char array. Use any number of white spaces after first string, scanf() treats as if there is only one white-space.
What about the white space at the begining then! scanf() simply ignores it! So, entering
Code:
[WS][WS][WS]trial[WS][WS][WS][WS]message[WS][CR]
will accept the strings "trial" and "message". All the WS (white spaces) characters will be ignored.
I think, scanf() does not thread a WS as a charater when it is the first.