На главную Наши проекты:
Журнал   ·   Discuz!ML   ·   Wiki   ·   DRKB   ·   Помощь проекту
ПРАВИЛА FAQ Помощь Участники Календарь Избранное RSS
msm.ru
Модераторы: Qraizer, Hsilgos
  
> Проблема с clrscr() , undeclared identifier
    ОСь: Windows
    Компилятор: VC++6(cl.exe)
    Здравствуйте. Подскажите пожалуйста в чем может быть проблема. При компиляции программы с вызовом функции clrsrc(), компилятор выдает ошибку:
    ExpandedWrap disabled
      error C2065: 'clrscr' : undeclared identifier

    Насколько мне известно, эта функция описывается в файле conio.h, но он подключен. Его замена ни чем не помогла.
    P.S. Не сочтите мой вопрос ламерским, просто я только начал изучать язык C :rolleyes:.
      Цитата h2all @
      clrscr
      - нету в VC, импользуй system("cls");

      Добавлено
      P.S. #include <stdlib.h>
      Сообщение отредактировано: Adil -
        Или подключить conio.h :)
          ExpandedWrap disabled
            /*Some non-Microsoft versions of C++ provide a clrscr function for clearing the screen in a DOS application.
            However, there is no Win32 Application Programming Interface (API) or C-Runtime function that will perform this function.
             
            There are two ways to accomplish this task for a Win32 console application. The first method is to use the system function as follows:*/
             
            #include <stdlib.h>
             
            void main()
            {
               system("cls");
            }
                            
             
            /*
            The second method is to write a function that will programmatically clear the screen.
            That method is described in the More Information section which follows.
            MORE INFORMATION
            The following function clears the screen: */
             
             /* 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;
             }
            Цитата Lyrik @
            Или подключить conio.h
            В котором нет clrscr :)
              Спасибо всем кто ответил. Получилось. Как быстро со всем разобрались.
              trainer, ты говоришь что в conio.h нет clrscr, но я на курсах использовал именно его <_< .
              P.S. А что нужно подключить чтобы заработала функция textbackground(), а то на курсах работает а дома нет :(
                Цитата h2all
                trainer, ты говоришь что в conio.h нет clrscr, но я на курсах использовал именно его

                в микрософтофском conio.h нет clrscr.
                И textbackground там тоже нет :)

                Может тебе все-таки на борланд перейти?
                Сообщение отредактировано: Adil -
                  Цитата Adil @
                  Может тебе все-таки на борланд перейти?
                  Или вернуться? :)
                    Действительно на курсах стоит Borland, а дома VC. А нельзя ли борландский conio.h подключать к проэктам на VC, и если нельзя, подскажите где можно почитать о vc's функциях по работе со цветом (textcolor, cputs и т.д.)?
                    Сообщение отредактировано: h2all -
                      :) В Visual C++ управление консолью можно соуществлять через WinAPI
                      0 пользователей читают эту тему (0 гостей и 0 скрытых пользователей)
                      0 пользователей:


                      Рейтинг@Mail.ru
                      [ Script execution time: 0,0297 ]   [ 16 queries used ]   [ Generated: 6.03.25, 16:36 GMT ]