Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Compress(char * a_File, char * a_ToFile)
- {
- char t_Line[128];
- FILE * t_File = fopen(a_File, "r+");
- if(t_File==NULL) return;
- FILE * t_WriteFile = fopen(a_ToFile, "w");
- fclose(t_WriteFile);
- t_WriteFile = fopen(a_ToFile, "a");
- if(t_File==NULL) return;
- char t_Char = 0;
- char t_Count = 0;
- for(int i = 0; fgets(t_Line, 128, t_File); i++)
- {
- for(int j = 0; j<=strlen(t_Line); j++)
- {
- if(t_Line[j]==t_Char) t_Count++;
- else
- {
- if(t_Count!=0)
- {
- fputc((int)t_Char, t_WriteFile);
- fputc ((int)t_Count, t_WriteFile);
- }
- t_Char = t_Line[j];
- t_Count = 1;
- }
- }
- }
- fclose(t_File);
- fclose(t_WriteFile);
- }
Advertisement
Add Comment
Please, Sign In to add comment