i need help regarding determining the longest word of a string..we would enter a sentence and the program would display the longest word/s i have read ideas about the strtok but i cant seem to understand it that much..and we havent discussed that yet so my prof might question it..i made a program of how i understand it... but it seems it does'nt work at all..here it goes..
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
void main()
{char fsentence[30],fword[20],flongest[]="",fflongest[20],j[10],r='\0';
int abc,def,ghi=0,lng=0;
printf("Input: ");
scanf("%s",&fsentence);
j[0]=fsentence[0];;
for(def=0;def<=strlen(fsentence);def++)
{if(isspace(fsentence[def])!=0)
{if(ghi>=lng)
{lng=ghi;
ghi=0;}
}
else
ghi++;}ghi=0;
for(def=0;def<=strlen(fsentence);def++)
{if(isspace(fsentence[def])!=0)
{if(ghi==lng)
{strncpy(fflongest,fsentence,def);
puts("fflongest");
strnset(fsentence,r,def);
ghi=0;
}else
ghi=0;strnset(fsentence,r,def);
}else
ghi++;
}
getch();}