In n * x, I use the following ANSI escape code to delete the current line and move the cursor to the beginning.
\033[0F\033[2K
So you would use it like this:
cout << "\033[0F\033[2K" << units << endl;
On the next page you can view all the details:
http://en.wikipedia.org/wiki/ANSI_escape_sequences
There is also a link on this page on how to achieve similar effects for windows.
source share