I have tried this following code with errors but I must have mistaken something: (you can improve it)
Code:
#include <stdio.h>
#include <stdlib.h>
#define MAXLEN 100
#define TRUE 1
int main(void)
{
char string[MAXLEN];
int i, j, length = 0, maxlength = 0;
system("cls");
printf("Enter your name, address, city and state or some text\n");
gets(string);
while(i = 0; string[i] != '\0'; i++)
{
for(j = 0; string[j] != ' '; j++) *I think this is not right*
{
length++;
if(length > maxlength)
maxlength = length;
}
string[j]++;
}
printf("Longest word have %d chracters\n", maxlength);
system("PAUSE");
return 0;
}