Josif_tepe

Untitled

Jun 5th, 2026
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5.  
  6.  
  7. int main(int argc, char * argv[]) {
  8.     if(argc < 2) {
  9.         printf("Ne vnesovte vlezna datoteka\n");
  10.         return 0;
  11.     }
  12.    
  13.    FILE * in = fopen(argv[1], "r");
  14.    if(in == NULL) {
  15.     printf("Datotekata ne postoi\n");
  16.     return 0;
  17.    }
  18.  
  19.    char c;
  20.    char niza[2000];
  21.    int i = 0;
  22.    int brojac = 0;
  23.    while((c = fgetc(in)) != EOF) {
  24.     if(c == '!' || c == ',') {
  25.         if(i >= 5) {
  26.             for(int j = 0; j < i; j++) {
  27.                 printf("%c", niza[j]);
  28.             }
  29.             printf("\n");
  30.             brojac++;
  31.  
  32.         }
  33.         i = 0;
  34.         niza[0] = '\0';
  35.     }
  36.     else if(c == '\n' || c == ' ') {
  37.         i = 0;
  38.         niza[0] = '\0';
  39.     }
  40.     else {
  41.         niza[i] = c;
  42.         i++;
  43.     }
  44.    }
  45.  
  46.    printf("%d\n", brojac);
  47.     return 0;
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment