Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <stdbool.h>
  4. bool letter(char a)
  5. {
  6. if ((a>='a' && a<='z') || (a>='A' && a<='Z'))
  7. return true;
  8. else return false;
  9. }
  10. int main() {
  11. FILE* f;
  12. if(!(f=fopen("/Users/ilabockov/Desktop/Каринка/aaa.txt","r+")))
  13. {
  14. printf ("error opening file");
  15. return 1;
  16. }
  17. char ch;
  18. int count=1;
  19. int size;
  20. int flag=0;
  21.  
  22. while (((ch=getc(f))!=EOF))
  23. {
  24. if (letter(ch)==false)
  25. {
  26. if(count==5){
  27. flag=1;
  28. break;
  29. }
  30. ch=getc(f);
  31. if (letter(ch)==true)
  32. {
  33. count ++;
  34. }
  35.  
  36. }
  37. if(flag==1){
  38. break;
  39. }
  40. if (count==5)
  41. {
  42. size++;
  43. printf ("%c",ch);
  44. }
  45. }
  46. fseek(f,-1,SEEK_CUR);
  47. int minussize=(-size)-1;
  48. while((ch=getc(f))!=EOF){
  49. fseek(f,minussize,SEEK_CUR);
  50. fputc(ch, f);
  51. fseek(f,size,SEEK_CUR);
  52. }
  53. fputc(f,'\0');
  54. printf ("%d\n",count);
  55. fclose (f);
  56. return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement