Hmm.. Niby można...
#include <stdio.h>
#include <stdlib.h>
size_t word_count(const char * msg, unsigned count)
{
return !msg ? 0 : !*msg ? count : \
word_count(msg + 1, count + (!count && *msg) + ((*msg) == ' '));
}
int main(void)
{
const char * msg_table[] = {
"Marysia ma Rysia.",
"Abelard Giza.",
"Ni",
NULL
};
size_t length = sizeof(msg_table) / sizeof(msg_table[0]);
size_t i;
for (i = 0; i < length; ++i)
{
printf("Zdanie: \"%s\", jest %zu słów/słowa.\n",
msg_table[i], word_count(msg_table[i], 0));
}
return EXIT_SUCCESS;
}
.. zawsze się trochę "powygłupiać". Ale tak pisać raczej się nie powinno.