Advertisement

Codewarrior question

Started by February 12, 2002 05:41 PM
13 comments, last by blooper 22 years, 6 months ago
This doesn't work: //libraries #include <iostream> #include <conio.h> //introduces namespace std using namespace std; int main( void ) { cout<<"Howdy"; __clrscr(); //thats how defined in conio.h... cin.get(); } I get an error: Link Error : Undefined symbol: ?__clrscr@@YAXXZ (void __clrscr()) in hello.cpp mmmmmmmm. Here it is in conio.h: /* Useful console I/O functions defined in conio.c */ void __initscr(void); int __kbhit(void); int __getch(void); int __getche(void); void __clrscr(void); <---------ummmmmm void __gotoxy(int x, int y); int __wherex(void); int __wherey(void); void __textattr(int newattr); void __textcolor(int newcolor); void __textbackground(int newcolor); I don't quite get it... Thanks ahead of time. Edited by - blooper on February 12, 2002 6:55:06 PM
try clrscr();

"I''ve learned something today: It doesn''t matter if you''re white, or if you''re black...the only color that REALLY matters is green"
-Peter Griffin
"I've learned something today: It doesn't matter if you're white, or if you're black...the only color that really matters is green"-Peter Griffin
Advertisement
All the functions in CW''s conio.h are preceeded by double underscores (__) (see above).

When I try plain clrscr() I get an "unidentified identifier ''clrscr''" error.
I''ve got a copy of codewarrior around here somewhere, I''m sure you just use clrscr() and for some reason you don''t put .h at the header declares.

If not email me and I''ll install and test it on my machine.


,Jay
//libraries
#include <iostream>
#include <conio>
#include <stdlib.h>

//introduces namespace std
using namespace std;

int main( void )
{
cout<<"Howdy";
//system("cls");
clrscr();
cin.get();
}

for \ i get: "the file conio can not be opened"
for clrscr() i get: "undefined identifier 'clrscr'"

Edited by - blooper on February 13, 2002 7:26:54 PM
Ok codewarrior does require __ but it totally sucks... required to use it at school. There are free compilers that are better. www.bloodshed.org or something is a freeware win gnu compiler.
Advertisement
Alright, I get no errors with this but the screen does not clear...Perhaps something is missing in CW, wrong with XP...? I just don''t know. __clrscr must and does exist otherwise I would get an error...but since I don''t it must exist (redundant I know)...and therefor is it the __clrscr function in XP only...(but then why doesn''t system("cls") work either)

//libraries
#include <iostream>
#include <conio.h>
#include <stdlib.h>

//introduces namespace std
using namespace std;

int main( void )
{
cout<<"Howdy"< //system("cls");
__clrscr;
//clrscr(); //thats how defined in conio.h...
cin.get();
}

This however does work, though my limited understanding of the whole thing makes me want to avoid tinkering with creating my own function just yet...

Here it is:

#include <windows.h>

void cls( HANDLE );

main(void) {
HANDLE hConsole;

// Get a handle to stdout
hConsole=GetStdHandle(STD_OUTPUT_HANDLE);
// Clear stdout
cls(hConsole);
}

// Det verkar som om MS har tagit bort clearscreen funktion ur win32 API
//
// NedanstÂende funktion ‰r kopierade (och l‰tt modifierad) frÂn MS KDB
//
void cls( HANDLE hConsole ) {
// here''s where we''ll home the cursor
COORD coordScreen = { 0, 0 };
BOOL bSuccess;
DWORD cCharsWritten;
// to get buffer info
CONSOLE_SCREEN_BUFFER_INFO csbi;
// number of character cells in the current buffer
DWORD dwConSize;

// get the number of character cells in the current buffer
bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi );
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;

// fill the entire screen with blanks
bSuccess = FillConsoleOutputCharacter( hConsole, (TCHAR) '' '',
dwConSize, coordScreen, &cCharsWritten );

// get the current text attribute
bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi );

// now set the buffer''s attributes accordingly
bSuccess = FillConsoleOutputAttribute( hConsole, csbi.wAttributes,
dwConSize, coordScreen, &cCharsWritten );

// put the cursor at (0, 0)
bSuccess = SetConsoleCursorPosition( hConsole, coordScreen );
return;
}
rewrite it ADDING the .h to make and REMOVE the namespace line.

then use clrscr();

If it won''t work then I will admit that I''m a snivling little pathetic excuse for a C++ programmer and I''ll eat my own VC++ CD

~Vendayan
"Never have a battle of wits with an unarmed man. He will surely attempt to disarm you as well"~Vendayan
No luck ....but thanks for your time in any case!
Alright, does anyone else with Codewarrior get this error/have this problem? Reinstall...but its all there.....

This topic is closed to new replies.

Advertisement