CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Posts
    1

    clrscr ( ) function

    I'm writing an app in console mode using Visual C++ 4.0 and after compiling, I get the following error messages:

    Myfile.obj:error LNK2001:unresolved external symbol "void_cdecl slrscr(void)"(?clrscr@@YAXXZ)

    Myfile.exe:fatal error LNK1120: 1 unresolved externals

    Can anybody help me?


  2. #2
    Join Date
    May 1999
    Posts
    31

    Re: clrscr ( ) function

    Hi,

    You are getting this message because the function clrscr() does not exist.

    You can use the following code to clear the screen:

    Note: This code is from MSDN, so it should work. If not, complain to MS.

    // Code starts here

    /* 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;
    }

    // Code Ends Here

    I hope this helps.

    Daniel.


  3. #3
    Join Date
    May 1999
    Location
    Atlanta, GA, USA
    Posts
    443

    Re: clrscr ( ) function exists

    Hi.

    clrscr() surely exists.
    You need the header file - conio.h

    #include <conio.h> //non-standard header file needed
    //for use of clear screen function clrscr.

    However, even though you type this header file on your project and
    you get error message, VC++ seems not to support this function.
    Turbo C++ supports this.(my school project two years ago)

    Hope for help.
    -Masaaki Onishi-


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured