There is no way in ANSI C to make a portable line-editor. If you roll your own, you will have to reroll it for every new operating system you want your program to work on.
If I may make a suggestion, I would use a pre-existing library to do all of that hard, platform-specific dirty work, and with that leg-up, learn how to handle things like arbitrary-length input and such. Then, when your code works (and is good), learn how to do all that dirty work, and take away the library-crutch. That way, you're not tackling the whole thing - you're breaking it down into more manageable parts.
Even this is a bit of an oversimplification. It took me quite a while to learn how to handle arbitrary-length input.
Also, know that, if you want your code to be portable, removing the library dependency will mean that, if you want to port it, you'll have to either a) rewrite all that dirty-work code, or b) add the library back in.
To end this all on a joke, this is your brain with libraries:
Pigmaei gigantum humeris impositi plusquam ipsi gigantes vident.
(If I have seen a little further it is by standing on the shoulders of Giants.)
--Isaac Newton
This is your brain without libraries:
If I have not seen as far as others, it is because giants were standing on my shoulders.
--Hal Abelson