Using of the function scanf with the format "%s" skips leading white spaces and reads characters until a white space is encountered.
So you can not enter a sentence using this format,
Instead use the standard function fgets.
Moreover take into account that the user can separate words with several spaces or tabs. In this case your output will be invalid because there will be many empty lines.
It is more efficient to use the standard C functions strspn and strcspn.
Here is a demonstrative program.
#include <stdio.h>
#include <string.h>
int main(void)
{
enum { N = 100 };
char str[N] = "";
printf( "Enter a Sentence: " );
fgets( str, N, stdin );
str[ strcspn( str, "\n" ) ] = '\0';
const char *p = str;
const char *delim = " \t";
while ( *p )
{
p += strspn( p, delim );
const char *q = p;
p += strcspn( p, delim );
if ( p != q )
{
printf( "%*.*s\n", ( int )( p - q ), ( int )( p - q ), q );
}
}
return 0;
}
If for example to enter the following statement
Have a nice day Luka Milicevic
then the program output will be
Enter a Sentence: Have a nice day Luka Milicevic
Have
a
nice
day
Luka
Milicevic