Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- #include <stdbool.h>
- bool letter(char a)
- {
- if ((a>='a' && a<='z') || (a>='A' && a<='Z'))
- return true;
- else return false;
- }
- int main() {
- FILE* f;
- if(!(f=fopen("/Users/ilabockov/Desktop/Каринка/aaa.txt","r+")))
- {
- printf ("error opening file");
- return 1;
- }
- char ch;
- int count=1;
- int size;
- int flag=0;
- while (((ch=getc(f))!=EOF))
- {
- if (letter(ch)==false)
- {
- if(count==5){
- flag=1;
- break;
- }
- ch=getc(f);
- if (letter(ch)==true)
- {
- count ++;
- }
- }
- if(flag==1){
- break;
- }
- if (count==5)
- {
- size++;
- printf ("%c",ch);
- }
- }
- fseek(f,-1,SEEK_CUR);
- int minussize=(-size)-1;
- while((ch=getc(f))!=EOF){
- fseek(f,minussize,SEEK_CUR);
- fputc(ch, f);
- fseek(f,size,SEEK_CUR);
- }
- fputc(f,'\0');
- printf ("%d\n",count);
- fclose (f);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement