求句子中最长的单词 为什么运行有乱码
#include<stdio.h>#include<string.h>
#include<malloc.h>
void main()
{
void longest(char []);
char string[15]="I am a student"; clrscr();
longest(string);
}
void longest(char a[])
{ int i=0,j,max=0,i1=0,j1=0,k=0;
while(a[i]!=' ')i++; max=i;i1=0;j1=i;
for(;a[i]!='\0';i++)
{ for(j=i;a[j]!=' ';j++)
if(max<j-i){max=j-i;j1=j;i1=i;}
}
printf("the longest word is: ");
for(k=i1;k<j1;k++)printf("%c",a[k]);
}