Help with <conio.h>'s clrscr();
Hi, I'm programming some pretty basic stuff in DOS, and I've tried to use the clrscr(); function, but I always get this error when I compile (w\ MSVC++ 6.0):
C:\Windows\test.cpp(15) : error C2065: 'clrscr' : undeclared identifier
Error executing cl.exe.
I'm a n00b :p , so I have no idea how to fix this, and get it to actually work. Help would be grately appreciated :D
Edited by - Anonymous Programmer on September 17, 2001 8:38:47 PM
Anonymous Programmer
do a search on your hd for the conio.h file... if you look inside it the function doesn''t exist. i checked out the MSDN and there used to be a function _clearscreen() but i dont think its supported anymore... i used to know a way to do it but its been a while... sorry :/
I''ve posted this a couple dozen times: clrscr isn''t a standard function, and you''re NOT programming for DOS if you''re using MSVC. You''re programming for Win32 Console, so you use the Win32 Console API:
[Resist Windows XP''s Invasive Production Activation Technology!]
// This code was borrowed from a wrapper by Eric Tetzbool Clear() { HANDLE hconsole = GetStdHandle (STD_OUTPUT_HANDLE); // get the number of character cells in the current buffer CONSOLE_SCREEN_BUFFER_INFO csbi; if (!GetConsoleScreenBufferInfo (hconsole, &csbi)) return false; COORD coordScreen = { 0, 0 }; // here''s where we''ll home the cursor DWORD cCharsWritten; // number of chars written by console output routines DWORD dwConSize = csbi.dwSize.X * csbi.dwSize.Y; // fill the entire screen with blanks return (FillConsoleOutputCharacter (hconsole, '' '', dwConSize, coordScreen, &cCharsWritten) && FillConsoleOutputAttribute (hconsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten) && SetConsoleCursorPosition (hconsole, coordScreen));}
[Resist Windows XP''s Invasive Production Activation Technology!]
Thanks Null & Void
Edited by - Anonymous Programmer on September 17, 2001 9:52:28 PM
Edited by - Anonymous Programmer on September 17, 2001 9:52:28 PM
Anonymous Programmer
Im a beginner too. I have a lot of question to ask.
(1) "bool Clear()". What is the meaning of bool?When should I use this?
(2) I have see a lot of game source code and I found out some command I never seen before. Example is:-
(a)hwnd=CreateWindowEx(0,NAME,TITLE,WS_POPUP,0,0,GetSystemMatrics(SM_CXSCREEN),NULL,NULL,hInstance,NULL);
(b)#include
(c)#include
Those command is it from VSC++ or some where else?
KOK@HOE
(1) "bool Clear()". What is the meaning of bool?When should I use this?
(2) I have see a lot of game source code and I found out some command I never seen before. Example is:-
(a)hwnd=CreateWindowEx(0,NAME,TITLE,WS_POPUP,0,0,GetSystemMatrics(SM_CXSCREEN),NULL,NULL,hInstance,NULL);
(b)#include
(c)#include
Those command is it from VSC++ or some where else?
KOK@HOE
KOK@HOE
from malaysia too, huh??? which state???
anyway, bool is the boolean type, in his case, it defines the return type of a function (am i right in this?? heh, i''m a newbie too...) in this way: 0 for false and non-zero for true
while the ur third line is used for programming in windows
and the #include is to include header (*.h) files
i woke up today and opened up the VC++, only to realise i only know QB
anyway, bool is the boolean type, in his case, it defines the return type of a function (am i right in this?? heh, i''m a newbie too...) in this way: 0 for false and non-zero for true
while the ur third line is used for programming in windows
and the #include is to include header (*.h) files
i woke up today and opened up the VC++, only to realise i only know QB
Error C0000: No dirty 4 letter words allowed
-=Idiot of the Net=-
-=Idiot of the Net=-
quote: Original post by minority
...0 for false and non-zero for true
Not always. The atual definitions for true and false are system dependent. All you need to know is that a boolean variable or condition (what you put in if and while statements are evaluted as boolean conditions) evaluates to one of true or false and a boolean function returns either true or false.
So you use bool as a return value when your function tells the caller whether a condition is true or false - use it when you wish to use the function in if and/or while statements, for example.
bool Clear();...if( Clear() ) { // either try to clear or find out if cleared... // do something in particular}
The C/C++ syntax defines only a few keywords. Anything that you see (such as CreateWindowEx()) which is unfamiliar is probably a function that you don''t know yet - and trust me, there are tons!
As minority said, the #include keyword literally includes the contents of another file in the current file. It goes like this: the compiler actually sees only implementation/source (.c/.cpp) files; header files contain declarations and inline functions that are inserted into the source files by something called the preprocessor . That''s why most keywords starting with the ''#'' symbol are called preprocessor directives : they give instructions to the preprocessor.
quote: Original post by Null and Void
I''ve posted this a couple dozen times: clrscr isn''t a standard function, and you''re NOT programming for DOS if you''re using MSVC. You''re programming for Win32 Console, so you use the Win32 Console API:// This code was borrowed from a wrapper by Eric Tetzbool Clear() { HANDLE hconsole = GetStdHandle (STD_OUTPUT_HANDLE); // get the number of character cells in the current buffer CONSOLE_SCREEN_BUFFER_INFO csbi; if (!GetConsoleScreenBufferInfo (hconsole, &csbi)) return false; COORD coordScreen = { 0, 0 }; // here''s where we''ll home the cursor DWORD cCharsWritten; // number of chars written by console output routines DWORD dwConSize = csbi.dwSize.X * csbi.dwSize.Y; // fill the entire screen with blanks return (FillConsoleOutputCharacter (hconsole, '' '', dwConSize, coordScreen, &cCharsWritten) && FillConsoleOutputAttribute (hconsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten) && SetConsoleCursorPosition (hconsole, coordScreen));}
[Resist Windows XP''s Invasive Production Activation Technology!]
Hum... not for dos ? well u can program for dos of course the probles is that microsoft is so gay that they change alot of things. but with borland c++ the clrscr(); will work fine. it''s just cuz microsoft is G@Y !
"The shortcut is not always the best way " ][v][etal ''][''yphoon
Metal Typhoon
quote: Original post by Metal Typhoon
well u can program for dos
Not in MSVC.
~~~~~~~~~~
Martee
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement