Fundamentals of C Programming/Useful functions

In this chapter, you will get some codes that you can use to make your program user-friendly. We see many programs daily. Can we make such programs using the 16 bit DOS environment? No, we cannot. But we can try to go as near to it as possible. With that in mind, there are certain functions that have been provided below that you may like to include in your program.

Boxes
In the programs we encounter everyday, we see that the output is in selected parts of the screen and not from the extreme left corner as in the programs we have seen so far. So how to construct such a box in DOS? Here is the code to do so:

Double line box
The coordinates passed to this function are the x and y coordinates of the top-left and the bottom-right corner of the box that we want to print. Then special characters for each corner are printed on the specified points on the screen. Then the horizontal and vertical lines are printed using the for loops. The space within them is then cleared using for loops and printing the ' ' character on the coordinates.You can try experimenting with the values that are passed on to drawbox and see the result.The function call of this function can be like:

These two calls will create two boxes on the screen. Even if you are not able to go into the depth of this function, you can use it with ease by pasting the code before the main function.