Untitled
unknown
plain_text
2 years ago
819 B
5
Indexable
int comprimi(FILE *fin, FILE *fout){ char c, testo[200]; int len=0,counter=0,tot=0; while(c=fgetc(fin)!= EOF){ testo[len] = c; len++; } while(counter <len){ if (testo[counter+1]==testo[counter]){ int add=0; while(testo[counter+2+add]==testo[counter+1] && add<9){ add++; } if (add!=0){ fprintf(fout,"%c$%d", testo[counter], add+'0'); counter = counter+2+add+1; tot = tot+3; }else{ fputc(testo[counter],fout); counter++; tot++; } }else{ fputc(testo[counter],fout); counter++; tot++; } } return tot; }
Editor is loading...