The elements of a char array are single characters, not words.
The fact that you (or I) deem that groups of characters separated by whitespace are words, doesn't make any difference to printf(). Using %s will cause printf() to write out the whole string (all the characters, one after the other, in one hit - no loop required by you). Using %c, in a loop, simply means you make the outputting of each character more explicit.
No need to "extract" the words if all you're going to do is print them in the same order, with whitespace in between.
However, this code will print each word in a string on a separate line.
Code:
#include <stdio.h>
#include <ctype.h>
void PrintWordsOnLine(const char s[])
{
int index = 0;
while (s[index] != 0)
{
if (isspace(s[index])) /* isspace checks for whitespace */
printf("\n");
else
printf("%c", s[index]);
++index;
}
printf("\n"); /* outputs a new line after the last word */
}
int main()
{
PrintWordsOnLine("The brown cow jumped over the moon");
return 0;
}
This does not exactly "extract" the separate words. It simply prints out all characters one at a time, but substitutes a carriage return for any whitespace character. So if there are multiple consecutive spaces, you'll see blank lines. At no point, however, is there something that represents a separate word. But this should be enough to get you started with extracting words, depending on what you actually mean by "extract".