Advertisement
sellmmaahh

AAABBBCCC

Feb 7th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.87 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. {  
  5.       char s[100], znak;
  6.     int i=0, vel, br;
  7.     FILE* Ulaz, *Izlaz;
  8.    
  9.     Ulaz=fopen("ulaz.txt", "r");
  10.     if (Ulaz==NULL)
  11.     {
  12.         printf("Greska pri otvaranju datoteke. ");
  13.         exit(1);
  14.     }
  15.     Izlaz=fopen("izlaz.txt", "w");
  16.     if (Izlaz==NULL)
  17.     {
  18.         printf("Greska pri otvaranju datoteke. ");
  19.         fclose(Ulaz);
  20.         exit(1);
  21.     }
  22.    
  23.  
  24.     while (fscanf(Ulaz,"%c", &niz[i])!=EOF && i<100)
  25.         i++;
  26.     vel=i;
  27.     for (i=o; i<vel; i++)
  28.     { znak=s[i];
  29.         br=0;
  30.         while (znak==s[i])
  31.         {
  32.             i++; br++;
  33.         }
  34.         while (br>255)
  35.         {
  36.             fprintf(Izlaz, "%c %c", znak, 255);
  37.             br-=255;
  38.         }
  39.         fprintf(Izlaz, "%c %c", znak, br);
  40.         i--;
  41.     }
  42.     fclose(Ulaz);
  43.     fclose(Izlaz);
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement