clearing screen

I have read the following already before anyone gets on me.
http://www.cplusplus.com/forum/beginner/1988/page3.html

I want to have my console clear the screen after user clears all input and when user wishes to continue. I went to the following link from that page and here is that link http://support.microsoft.com/kb/99261
The following code is there but i am not sure how to put it in my code. here is the code listed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 /* Standard error macro for reporting API errors */ 
 #define PERR(bSuccess, api){if(!(bSuccess)) printf("%s:Error %d from %s \ 
    on line %d\n", __FILE__, GetLastError(), api, __LINE__);}

 void cls( HANDLE hConsole )
 {
    COORD coordScreen = { 0, 0 };    /* here's where we'll home the
                                        cursor */ 
    BOOL bSuccess;
    DWORD cCharsWritten;
    CONSOLE_SCREEN_BUFFER_INFO csbi; /* to get buffer info */ 
    DWORD dwConSize;                 /* number of character cells in
                                        the current buffer */ 

    /* get the number of character cells in the current buffer */ 

    bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi );
    PERR( bSuccess, "GetConsoleScreenBufferInfo" );
    dwConSize = csbi.dwSize.X * csbi.dwSize.Y;

    /* fill the entire screen with blanks */ 

    bSuccess = FillConsoleOutputCharacter( hConsole, (TCHAR) ' ',
       dwConSize, coordScreen, &cCharsWritten );
    PERR( bSuccess, "FillConsoleOutputCharacter" );

    /* get the current text attribute */ 

    bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi );
    PERR( bSuccess, "ConsoleScreenBufferInfo" );

    /* now set the buffer's attributes accordingly */ 

    bSuccess = FillConsoleOutputAttribute( hConsole, csbi.wAttributes,
       dwConSize, coordScreen, &cCharsWritten );
    PERR( bSuccess, "FillConsoleOutputAttribute" );

    /* put the cursor at (0, 0) */ 

    bSuccess = SetConsoleCursorPosition( hConsole, coordScreen );
    PERR( bSuccess, "SetConsoleCursorPosition" );
    return;
 } 

i know to put the function below the main section in the .cpp and i think i need the windows.h file to be inclued it is the top two lines i need to know where to put and how to call the function in the main section of the .cpp file.

I have also downloaded the pdcurse file how do i get that into use i am using visual c++ 20008 express that seems to have a clear screen function in it also
If you want to clear the screen, try system("CLS"); It's platform dependent, but it is much simpler.
i figured that out but i would like to do it right instead of the the improper way. From all i have read using the system way can lead to other problems besides being system dependant. i would like to learn how to impliment this code to further my learning of the language and for future projects. so if anyone else can give me help with this problem without starting a flame war like in the one article i mentioned in this forum i would appreciate it. I am try to honestly learn new principles and to improve my skills. Again tahnk you for your help
Topic archived. No new replies allowed.