strtok is your friend:
char a[] = "You are welcome";
char b[5][20] = {{0}};
char *pch;
pch = strtok( a," \t" );
int i = 0;
while( NULL != pch && i < 5)
{
strcpy(b[i++], pch);
pch = strtok( NULL, " \t\n" );
}
for( i = 0; i < 5; i++ )
{
if( strlen(b[i]) > 0 )
{
printf( "b[%d] = %s\n", i, b[i] );
}
}
Don't forget to #include <string.h>
As David C. Rankin pointed out. We can do away with strlen by just checking the first char not \0. So this'd be a better solution (note that the main while loop for strtok processing remains the same).
i = 0;
while (*b[i])
{
printf( "b[%d] = %s\n", i, b[i] );
i++;
}