Although other answers already pointed you to box drawing characters, you should be careful using hardcoded terminal sequences in your app on your own as given in those answers. Note that there might be terminals that simply dont understand these sequences and will output some rubbish instead.
If you dont understand anything of this, either restrain from using those sequences or use a library, thats capable of handling terminal awkwardities in a uniform way, like ncurses. Those libraries also have a primitive for drawing a horizontal line (with proper fallbacks).
If you are still keen to get this done yourself and without the help of a terminal DB like libterminfo, you have the following possibilities:
- lookup whether the terminal you want to address supports all the sequences + characters to send (if not, find some replacement), repeat that for every terminal you want to support
- if your target terminal(s) support Unicode (UTF-8) you might get away with directly inserting the corresponding Unicode chars (test whether sending U+2500 shows up correctly)