How to clear screen in MS VC?

One option is to use

[sourcecode language=’cpp’]system( “cls” );[/sourcecode]

Another option is to to use this function. I copied this from MSDN.  😉

[sourcecode language=’cpp’]void cls( HANDLE hConsole )
{
/* here’s where we’ll home the cursor */

   COORD coordScreen = { 0, 0 };

   BOOL bSuccess = FALSE;
   DWORD cCharsWritten = 0;

/* to get buffer info */
   CONSOLE_SCREEN_BUFFER_INFO csbi = { 0 };

/* number of character cells in the current buffer */
   DWORD dwConSize;

/* get the number of character cells in the current buffer */
   bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi );
   dwConSize = csbi.dwSize.X * csbi.dwSize.Y;

/* fill the entire screen with blanks */
   bSuccess = FillConsoleOutputCharacter( hConsole,
( TCHAR )’ ‘,
     dwConSize,
coordScreen,
&cCharsWritten );

   /* get the current text attribute */
  bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi );

/* now set the buffer’s attributes accordingly */
   bSuccess = FillConsoleOutputAttribute( hConsole,
csbi.wAttributes,
      dwConSize,
coordScreen,
&cCharsWritten );
   /* put the cursor at (0, 0) */
   bSuccess = SetConsoleCursorPosition( hConsole, coordScreen );
   return;
}// End cls[/sourcecode]

Appreciate your comments...