There are a number of ways to read up to the first space and then do something else. The easiest of which would be:
Code:
if ( fgets ( a, sizeof a, stdin ) != NULL ) {
if ( sscanf ( a, "%s %[^\n]", b, c ) == 2 )
printf ( "%s\n%s\n%s\n", a, b, c );
else
/* Report error and handle */
}
else
/* Report error and handle */
But a safer way would be to modify the input so that there is a delimiting character not in the real data which separates the strings that you want, like so:
one : meaning of one
You can then use the : as the separator. That way you don't have to worry about the spacing of the input, such as if someone forgets to put a space between "one" and "meaning":
one-meaning of one
This would result in "one-meaning" being the word entry and "of one" being the definition. Not quite what you want.
-Prelude