C Example: Run-Length Encoding: compress, decompress and verify the round trip
A complete RLE codec: encodes runs of repeated characters as count+character, decodes them back, and verifies round-trip equality on three inputs. Handles two-digit counts such as 12W and text with no repeats — a basic technique for text and binary preprocessing.
🖥 Run OnlineGCC 10.2 · C11 standard · click ▶ to run · Copy code
🖨 Reference OutputMatches the online run in a standard C11 environment
input : AAABBBCCCD encoded : 3A3B3C1D decoded : AAABBBCCCD roundtrip: OK input : AB encoded : 1A1B decoded : AB roundtrip: OK input : WWWWWWWWWWWW encoded : 12W decoded : WWWWWWWWWWWW roundtrip: OK
🧩 Keep Learning