SHARE
TWEET

Untitled

a guest Jun 24th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // нахождение и вывод 5-го слова из файла
  2. #include <stdio.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(int argc, const char * argv[]) {
  11.     FILE* f;
  12.     if(!(f=fopen("/Users/ilabockov/Desktop/Каринка/red.txt","r+t")))
  13.     {
  14.         printf ("error opening file");
  15.         return 1;
  16.     }
  17.     char ch;
  18.     int count=1;
  19.  
  20.   while (((ch=getc(f))!=EOF))
  21.    {
  22.       if (letter(ch)==false)
  23.    {
  24.        ch=getc(f);
  25.     if (letter(ch)==true)
  26.        {
  27.            count++;
  28.         }
  29.          
  30.       }
  31.        if (count==5)
  32.        {
  33.          printf ("%c",ch);
  34.         }
  35.  
  36.     }
  37.     printf ("%d\n",count);
  38.     fclose (f);
  39.     return 0;
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top