Advertisement
Josif_tepe

Untitled

Jan 18th, 2024
623
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.96 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <string.h>
  4.  
  5. int main(int argc, const char * argv[]) {
  6.  
  7.     if(argc < 3) {
  8.         printf("Vlezna  datoteka i izlezna treba da se vnesat kako argument\n");
  9.         return 0;
  10.     }
  11.     FILE *in = fopen(argv[1], "r");
  12.     FILE * out = fopen(argv[2], "w");
  13.  
  14.     if(in == NULL) {
  15.         printf("Fajlot ne postoi\n");
  16.         return 0;
  17.     }
  18.     if(out == NULL) {
  19.         printf("Fajlot ne postoin\n");
  20.         return 0;
  21.     }
  22.  
  23.     char s[2000];
  24.     int red = 1, brojac = 0;;
  25.     while(fgets(s, 1000, in) != NULL) {
  26.         int golemi_bukvi = 0;
  27.  
  28.         for(int i = 0; i < strlen(s); i++) {
  29.             if(isalpha(s[i]) && isupper(s[i])) {
  30.                 golemi_bukvi++;
  31.             }
  32.         }
  33.         if(golemi_bukvi < 5) {
  34.             fprintf(out, "Red %d\n", red);
  35.             brojac++;
  36.         }
  37.         red++;
  38.     }
  39.      
  40.    fprintf(out, "Postojat %d takvi redovi\n", brojac);
  41.     return 0;
  42. }
  43.  
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement