Ah, heh! I imagine there's a readline library you can pull in. I also used to use the trick of running stuff under rlwrap - it intercepts input and adds editing support; the program run under it only sees stuff after you send it on through rlwrap. Run like rlwrap cat. Includes line history as well. :)

//