不要调用什么split之类的函数(questions like this one is intended to be a practice of detail implementation, not calling other functions)
https://oj.leetcode.com/discuss/9148/my-simple-solution-in-c
我的code,参考了discuss
<span style="font-family:Microsoft YaHei;font-size:14px;">int lengthOfLastWord(char *s) {
int count = 0;
while(*s){
if(*s++ != ' '){
count++;
}else if(*s != '\0' && *s != ' '){
count = 0;
}
}
return count;
}</span>