#include<stdio.h>
#include<stdlib.h>
main()
{
char reading[30]={0},store[30]={0};
int length,maxlength=0,i=0,j,k;
printf("input the string('#' to end):\n");
while((reading[0]!='#')&&(reading[0]!='.')&&(reading[i]!='#'))
{
scanf("%s",reading);
length=0;
i=0;
while((reading[i]!='\0')&&(reading[i]!='#')&&(reading[i]!='.'))
{
length++;
i++;
}
if(length > maxlength)
{
maxlength = length;
strcpy(store,reading);
}
}
printf("the longest word is: ");
for(k=0;k<=maxlength-1;k++)
printf("%c",store[k]);
system("pause");
return 0;
}
#include<stdlib.h>
main()
{
char reading[30]={0},store[30]={0};
int length,maxlength=0,i=0,j,k;
printf("input the string('#' to end):\n");
while((reading[0]!='#')&&(reading[0]!='.')&&(reading[i]!='#'))
{
scanf("%s",reading);
length=0;
i=0;
while((reading[i]!='\0')&&(reading[i]!='#')&&(reading[i]!='.'))
{
length++;
i++;
}
if(length > maxlength)
{
maxlength = length;
strcpy(store,reading);
}
}
printf("the longest word is: ");
for(k=0;k<=maxlength-1;k++)
printf("%c",store[k]);
system("pause");
return 0;
}