• Advertisement

Archived

This topic is now archived and is closed to further replies.

C++ newbie problem

This topic is 5715 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

#include <iostream.h> #include <conio.h> void main(void) { clrscr(); cout << "Hello World"; } compiler: error C2065: ''clrscr'' : undeclared identifier what is the problem? sorry if it is a REALLY stupid question...

Share this post


Link to post
Share on other sites
Advertisement
I don''t think there is a clrscr() procedure. I looked through the VC++6 docs and there isn''t one listed there either.

-Sam.

Share this post


Link to post
Share on other sites
Im not very well acquainted with the standard library but clrscr() is not a function there and I dont know of an equivalent.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
#include <iostream>

void main(void){
std::cout<<"Hello gamedev!";
}

Share this post


Link to post
Share on other sites
its
system("CLS");

i think...

and include

BTW undeclared identifier means that it doesnt exist(in your Include's or Libraries).

[edited by - pipo declown on June 29, 2002 11:27:19 AM]

Share this post


Link to post
Share on other sites
There MOST DEFINITELY is a clrscr() function!!!! I don''t know why anyone would tell you otherwise without knowing more on the subject. The clrscr() function is part of the conio.h library, which you need to include. If you are including conio.h and it still is not working, you may have a problem with the compiler or you may have a bad version of conio.h. I think the most likely problem, though, is that the libraries may not be in your include folder. Exactly what errors are you getting?

Share this post


Link to post
Share on other sites
clrscr was specific to borland compilers I believe. Search through the general programming, or for beginners forum it has been asked hundreds of times. There are solutions ranging from system("cls") to more robust functions that emulate clrscr. For instance:


    
void clrscr()
{
static HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
COORD coord = {0, 0};
DWORD dw;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwSize;

GetConsoleScreenBufferInfo(hConsole,&csbi);
dwSize = csbi.dwSize.X * csbi.dwSize.Y;

FillConsoleOutputCharacter(hConsole,
' ',
dwSize,
coord,
&dw);
FillConsoleOutputAttribute(hConsole,
csbi.wAttributes,
dwSize,
coord,
&dw);
SetConsoleCursorPosition(hConsole, coord);
}






[My site|SGI STL|Bjarne FAQ|C++ FAQ Lite|MSDN|Jargon]
Ripped off from various people

[edited by - wild_pointer on June 30, 2002 1:06:19 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by hmsimha
There MOST DEFINITELY is a clrscr() function!!!!

Not in Standard C or C++ there isn''t.
quote:

I don''t know why anyone would tell you otherwise without knowing more on the subject.

Because it''s correct.
quote:

The clrscr() function is part of the conio.h library, which you need to include.

That''s not a Standard header, but a vendor-supplied extension.

Share this post


Link to post
Share on other sites
I believe you have to include dos.h. If it is not that then it is something else because I have used clrscr.

Share this post


Link to post
Share on other sites
here is the code that would do what you want:

    
#include <iostream>
#include <stdlib.h>

int main(int argc, char *argv[])
{
system("CLS");
std::cout<<"Hello world!";

return 0;
}

forgot, this is very platform dependant, so, for example that is the windows version, for linux, as another example, you would replace "cls" with "clear"

[edited by - pointer0death on June 30, 2002 7:14:17 PM]

Share this post


Link to post
Share on other sites
clrscr() is a Borland function and not part of the standard. Doing system("CLS") should work, but it isn''t the most efficient thing, if that matters. You can pick up something like pdcurses.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
When in doubt go see google:

http://www.phanderson.com/C/clrscr.html

http://www.delorie.com/djgpp/doc/libc/libc_105.html

http://www.newbie.org/snippets/chats/bcb4/message/23.html

now take your own conclusions...

Share this post


Link to post
Share on other sites

  • Advertisement