Longest Line In C

This program accepts multiple string from user as input.After accepting the string,it calculates the length of all strings and displays it.The variable str stores the input string ,variable cnt is used to count the characters from each word and the varible max is used to store largest varible cnt.

The string str is parsed character by character.'\0' represents end of the string and ' ' represents space between two words. Counter cnt is incremented until ' ' occurs.When ' ' occurs ,the counter cnt is compared with variable max and if it larger than max then its value is assigned to variable max.This process continous until the string ends i.e. '\0' occurs.When the string terminates ,the variable max stores the longest string.

#include < stdio.h >
#include < conio.h > 
void main()
{
	char str[100];
	int max,i,cnt;
	clrscr();
	printf("Enter the String\n");
	flushall();
	gets(str);
	max=cnt=0;
	for(i=0;str[i]!='\0';i++)
	{
		if(cnt>max)
		{
			max=cnt;
		}
		if(str[i]!=' ')
			cnt++;
		else
			max=cnt;
	}
	printf("The length of longest line is %d",max);
}