Advertisement
machkovskitomche

datoteka

Sep 1st, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.94 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include <ctype.h>
  4. #define WORDLEN 21
  5. #define LINELEN 81
  6. #define bukva(c) isalpha(c)
  7. int ima_poveke_od2isti(char *w)
  8. {
  9. char *c;
  10. int isti;
  11. while(*w)
  12. { c=w+1;
  13. isti=1;
  14. while(*c)
  15. { if(tolower(*w)==tolower(*c))
  16. isti++;
  17. c++;
  18. }
  19. if(isti>2)
  20. return(1);
  21. w++;
  22. }
  23. return(0);
  24. }
  25. int main(int argc, char *argv[])
  26. {
  27. char zbor[WORDLEN],c;
  28. FILE *f;
  29. int iw=0,i=0,brzb=0;
  30. int ima2isti(char *);
  31. if(argc>2)
  32. { printf("Upotreba: %s ime_na_datoteka\n",argv[0]);
  33. return(-1);
  34. }
  35. if(argc==1)
  36. f=stdin;
  37. else
  38. if((f=fopen(argv[1],"r"))==NULL)
  39. { printf("Ne mozam da ja najdam datotekata %s\n",argv[1]);
  40. return(-1);
  41. }
  42. while((c=fgetc(f))!=EOF)
  43. { if(bukva(c))
  44. {
  45. if(!iw)
  46. iw=1;
  47. zbor[i++]=c;
  48. }
  49. else
  50. if(iw)
  51. {
  52. zbor[i]=0;
  53. if(ima_poveke_od2isti(zbor))
  54. {puts(zbor);
  55. brzb++;}
  56. zbor[i=iw=0]=0;
  57. }}
  58. printf("\nVkupno %d zborovi.\n",brzb);
  59. return (0);
  60. }
  61. //datoteka; proverva kolku zboroj imat po 2bukvi isti vnatre vo zborot
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement