题解 | #字符串最后一个单词的长度# 手撕c代码
字符串最后一个单词的长度
https://www.nowcoder.com/practice/8c949ea5f36f422594b306a2300315da
#include <stdio.h> #include <string.h> int main() { char str[5000]; char *arr[5000]; int size; int i = 0; scanf("%[^\n]",str);//gets(str); char *temp = strtok(str," "); while(temp) { arr[i] = temp; temp = strtok(NULL," "); i++; } size = strlen(arr[i-1]); printf("%d",size); return 0; }