//沒用指針, 是數組, 應該沒問題吧
//字符串中的單詞可以用多個空格隔開。
# include <stdio.h>
# include <string.h>
# define LEN 1000
# define N 256
void f(char *s)
{
int i=0, j=0, k=0, t=0;
char str[N],ss[N];
for(i=0;s[i];i++)
{
if(' ' == s[i])
{
str[k] = '\0';
if(' ' == str[0])
{
for(t=0;str[t];t++)
{
str[t] = str[t+1];
}
str[t] = '\0';
}
if(strlen(str)>j)
{
strcpy(ss, str);
j = strlen(str);
}
strcpy(str,"");
k=0;
i++;
}
str[k] = s[i];
k++;
}
strcpy(s, ss);
}
int main(void)
{
char s[LEN] = " abcde abcdefghijklmnopqrstuvwxyz re mmtr stremd sgrmoremssss rms";
f(s);
printf("字符串中最長的單詞是:%s\n", s);
return 0;
}