Anonymous user
Run-length encoding/C: Difference between revisions
m
no edit summary
m (→Unbuffered - Generative: minor reformat of code and comment) |
mNo edit summary |
||
Line 14:
#include <string.h>
const char *input = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW";
const char *output = "12W1B12W3B24W1B14W";
typedef void (*YIELDCHAR)(); /* yields via yield_init */
Line 45:
#define YIELDS(type) BOOL (*yield)(type) = yield_init
ITERATOR gen_char_seq (const char *s){
YIELDS(char);
fflush(stdout);
Line 79:
}
const char *zero2nine = "0123456789";
ITERATOR gen_decode (GENCHAR gen_char){
Line 94:
}
int main(){
/* iterate through input string */
printf("Encode input: ");
Line 108:
OD;
printf("\n");
return 0;
}</lang>
Output:
Line 185 ⟶ 186:
}</lang>
In the following codes, encoding and decoding are
'''Encoding filter'''
Line 205 ⟶ 206:
}
printf("%d%c", i, cp);
return 0;
}</lang>
Line 218 ⟶ 220:
for(j=0; j < i; j++) printf("%c", c);
}
return 0;
}</lang>
|