Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main() {
- char a, b;
- unsigned cnt = 1;
- FILE *f, *g;
- f = fopen("in.txt", "r");
- g = fopen("out.txt", "w");
- fscanf(f, "%c", &a);
- while (!feof(f)) {
- fscanf(f, "%c", &b);
- if (a == b) cnt++;
- else{
- fprintf(g, "%c%u", a, cnt);
- a = b;
- cnt = 1;
- }
- }
- fclose(f);
- fclose(g);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment