hi every one. i want some help in writing the code to find out shortest word in a string. i am posting a code on longest word. can somebody help me in writing this code?
this is the code for longest word in a string without any built in function
#include<stdio.h>
#include<conio.h>
void main()
{
int i,max=0,count=0,j;
char str[100];
clrscr();
printf("\nEnter the string\n:");
gets(str);
for(i=0;str[i]!='\0';i++)
{
if(!(str[i]==' '))
{
count++;
}
else
{
if(max<count)
{
j=i-count;
max=count;
}
count=0;
}
}
if(max<count)
{
j=i-count;
max=count;
}
for(i=j;i<(j+max);i++)
printf("%c",str[i]);
getch();
}