Advertisement
LegoDrifter

Datoteki 11

Jun 17th, 2020
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.42 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4. #include <string.h>
  5. int samoglaska(char *c)
  6. {
  7.     c = tolower(c);
  8.     if( c == 'a' || c == 'e'||  c == 'i' || c == 'o' || c == 'u') return 0;
  9.     else return 1;
  10. }
  11. int proverka(char *c)
  12. {
  13.  
  14.     if(strlen(c)>6)
  15.     {
  16.         if(samoglaska(c[0])&&samoglaska(c[strlen(c)-1]))
  17.             return 1;
  18.     }
  19.     return 0;
  20. }
  21.  
  22.  
  23.  
  24. int main()
  25. {
  26.     FILE *fPointer;
  27.     fPointer = fopen("test.txt","w");
  28.     fprintf(fPointer,"ttvaaaat e dsmdedd za da vidime sedum osum devet deset.");
  29.     fclose(fPointer);
  30.  
  31.     FILE *fPointer1;
  32.     fPointer1 = fopen("test.txt","r");
  33.     char ch;
  34.     int brojac=0;
  35.     char zbor[100];
  36.     int vkupno=0;
  37.     int voZbor=0;
  38.  
  39.     while((ch=fgetc(fPointer1))!=EOF)
  40.     {
  41.         if(isalpha(ch))
  42.         {
  43.             if(!voZbor)
  44.             {
  45.                 voZbor=1;
  46.             }
  47.             zbor[brojac]=ch;
  48.             brojac++;
  49.         }
  50.         else if(voZbor)
  51.         {
  52.             voZbor=0;
  53.             zbor[brojac]='\0';
  54.             if(proverka(zbor))
  55.             {
  56.                 puts(zbor);
  57.                 vkupno++;
  58.             }
  59.             zbor[0]='\0';
  60.             brojac=0;
  61.         }
  62.     }
  63.     if(voZbor)
  64.     {
  65.         zbor[brojac]='\0';
  66.         if(proverka(zbor))
  67.         {
  68.             puts(zbor);
  69.             vkupno++;
  70.         }
  71.     }
  72.     printf("Vkupno %d",vkupno);
  73.  
  74.  
  75.     return 0;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement