Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // нахождение и вывод 5-го слова из файла
- #include <stdio.h>
- #include <stdbool.h>
- bool letter(char a)
- {
- if ((a>='a' && a<='z') || (a>='A' && a<='Z'))
- return true;
- else return false;
- }
- int main(int argc, const char * argv[]) {
- FILE* f;
- if(!(f=fopen("/Users/ilabockov/Desktop/Каринка/red.txt","r+t")))
- {
- printf ("error opening file");
- return 1;
- }
- char ch;
- int count=1;
- while (((ch=getc(f))!=EOF))
- {
- if (letter(ch)==false)
- {
- ch=getc(f);
- if (letter(ch)==true)
- {
- count++;
- }
- }
- if (count==5)
- {
- printf ("%c",ch);
- }
- }
- printf ("%d\n",count);
- fclose (f);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement