#include "stdafx.h"
#include <stdio.h>
#include <ctype.h>
#include <conio.h>
int main ()
{
FILE * f;
int nmax = 0, pos = 0, wpos = 0,n = 0;
char chr = '\0';
if(!(f = fopen("test.txt","r+")))
printf("\tERROR : file not exist or already open\r\n");
else
{
while(!feof(f))
{
fread(&chr,1,1,f);pos = ftell(f);n = 0;
while(isalpha(chr) && !feof(f))
{
fread(&chr,1,1,f);
n++;
}
if(nmax < n)
{
wpos = pos;
nmax = n;
}
}
fseek(f,wpos - 1,SEEK_END);
fprintf(f, "\n %d \n", nmax);
fread(&chr,1,1,f);pos = ftell(f);n = 0;
while(isalpha(chr) && !feof(f))
{
fread(&chr,1,1,f);
}
printf("\r\n>END OF PROGRAM\r\n");
}
scanf("%c",&chr);
fclose (f);
getch ();
return 0;
}