CCCPaste

Untitled

#include 
#include 
#include 

int main(int argc, const char * argv[]) {

    if(argc < 3) {
        printf("Vlezna  datoteka i izlezna treba da se vnesat kako argument\n");
        return 0;
    }
    FILE *in = fopen(argv[1], "r");
    FILE * out = fopen(argv[2], "w");

    if(in == NULL) {
        printf("Fajlot ne postoi\n");
        return 0;
    }
     char s[2000];
     while(fgets(s, 1000, in) != NULL) {
         for(int i = 0; i < strlen(s); i++) {
             if(isdigit(s[i])) {
                 int x = (s[i] - '0');
                 int j = i + 1;
                 while(j < strlen(s) && x > 0) {
                     fprintf(out, "%c", s[j]);
                     x--;
                     j++;
                 }
                 i = j - 1;
             }
         }
     }
   
    return 0;
}