+ 4
@Derick, why did you link @Gaurav's code? did you ask for permission? if you have a code related question link your code, not others', that's inappropriate.
About your question, centering text in a console is a rather difficult thing to do nowadays, there are aspects to consider, the device's screen resolution defines how many characters would fit a row without leaking to the next row. In the old days, it used to be x/2 - l/2; where x is the maximum number of characters in a row, and l is the length of the string to be printed at the center of screen.
Hth, cmiiw