Jump to content
  • Advertisement

Archived

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

runtime

C++ newbie problem

This topic is 5951 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
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!