First of all, "run length compression" is a bit too wide term. You can compress data using run-length approach in a number of similar ways. Do you mean RLE? The here is the implementation:
[
^], see also
http://en.wikipedia.org/wiki/Run-length[
^].
As to your C code, I cannot see even the attempt of creation of encoding/decoding function. Instead, you've just written some
main
function. Why? Ever heard of functions and other means of
abstraction? Don't entangle I/O into algorithm, to start with.
—SA