Задача: Код
Исходник: лаба-2 по С, язык: C [code #622, hits: 10947]
аноним: Володька [добавлен: 17.03.2011]
  1. #include "stdafx.h"
  2. #include <stdio.h>
  3. #include <ctype.h>
  4. #include <conio.h>
  5.  
  6. int main ()
  7. {
  8. FILE * f;
  9. int nmax = 0, pos = 0, wpos = 0,n = 0;
  10. char chr = '\0';
  11.  
  12. printf(">LAB_3(VAR_3)\r\n");
  13. if(!(f = fopen("test.txt","r+")))
  14. printf("\tERROR : file not exist or already open\r\n");
  15. else
  16. {
  17. while(!feof(f))
  18. {
  19. fread(&chr,1,1,f);pos = ftell(f);n = 0;
  20. while(isalpha(chr) && !feof(f))
  21. {
  22. fread(&chr,1,1,f);
  23. n++;
  24. }
  25. if(nmax < n)
  26. {
  27. wpos = pos;
  28. nmax = n;
  29. }
  30. }
  31. fseek(f,wpos - 1,SEEK_END);
  32. printf("max: %d", nmax);
  33. fprintf(f, "\n %d \n", nmax);
  34. fread(&chr,1,1,f);pos = ftell(f);n = 0;
  35. while(isalpha(chr) && !feof(f))
  36. {
  37. fread(&chr,1,1,f);
  38. printf("%s",chr);
  39. }
  40. printf("\r\n>END OF PROGRAM\r\n");
  41. }
  42. scanf("%c",&chr);
  43. fclose (f);
  44. getch ();
  45. return 0;
  46. }

+добавить реализацию