int LengthOfLastWord(const char *s)
{
if(*s == '\0')return 0;
int count = *s ==' '?0:1;
while(*(++s) != '\0')
{
if (*s != ' ')
if (*(s-1) == ' ')
count = 1;
else
++count;
}
return count;
}
#include <stdio.h>
int main(int argc, char** argv)
{
char a[] = "hello world";
char b[] = "How are you ";
printf("%d\n", LengthOfLastWord(a));
printf("%d\n", LengthOfLastWord(b));
return 0;
}