C语言编程输入字符串,找出其中最长单词(要自定义函数)
来源:百度知道 编辑:UC知道 时间:2024/05/10 23:06:51
自己设置函数编程
char * max(char ** wordlib,int num)// num is the number of the words
{
int length = 0;
int c = 0;
int w = 0;
int i = 0;
int max;
for(;c<n;c++)
{
i = 0;
w = 0;
while(wordlib[c][i]!=0)//a word should be ended by a '\0'
{
i++;
w++;
}
if(w> length)
{
length = w;
max = c;
}
}
return wordlib[c];
}