Advertisement
Josif_tepe

Untitled

May 29th, 2024
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <ctype.h>
  4.  
  5. int main(int argc, char * argv[]) {
  6.     if(argc < 3) {
  7.         printf("Imeto na vlezna i izlezna datoteka se vnesuvaat kako argumenti od komadna linija\n");
  8.         return 0;
  9.     }
  10.     FILE *in = fopen(argv[1], "r");
  11.     FILE *out = fopen(argv[2], "w");
  12.  
  13.     if(in == NULL) {
  14.         printf("Ne vnesovte validna datoteka za vlez\n");
  15.         return 0;
  16.     }
  17.     if(out == NULL) {
  18.         printf("Ne vnesovte validna datoteka za pecatenje\n");
  19.         return 0;
  20.     }
  21.     int j = 0;
  22.     char niza[2000];
  23.     char c;
  24.     while((c = fgetc(in)) != EOF) {
  25.         if(isalpha(c)) {
  26.             niza[j] = c;
  27.             j++;
  28.         }
  29.         else {
  30.             if(isupper(niza[0]) && j % 2 == 0) {
  31.                 for(int i = 0; i < j; i++) {
  32.                     fprintf(out, "%c", niza[i]);
  33.                 }
  34.                 fprintf(out, "\n");
  35.             }
  36.             j = 0;
  37.         }
  38.     }
  39.  
  40. }
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement