Our school makes us use it as well. Sad. Anyway, i had that problem once, so my teacher loosed it up and told me to use consol.h instead. However I dont know if that works or not because I ended up not needing to clear the screen. You might try it though.
"cogito, ergo sum" -Descartes
Codewarrior question
Even though I''ve never used CodeWarrior, I have a thought. Disclaimer: I don''t know if this will work. First, a bit of theory.
To distinguish between let''s say
and
in C++, the compiler uses something called name mangling. Basically, it encodes parameter types into function name. Here''s an example:
YAXXZ is the parameter information; in this case, there are no parameters.
Now, in C you don''t need name mangling because you can''t overload functions. Therefore, function is called ___clrscr. The compiler always adds an extra underscore in front of C function names, that has to do with calling convention.
Since clrscr is the C function, its real name is ___clrscr, not ?__clrscr@@YAXXZ. Why are you getting the latter name? That''s because C++ compiler thinks it''s a C++ function.
To fix this, add the following around #include <conio.h>:
This tells the compiler to treat functions in conio.h as C functions, which is what they are. The real puzzle to me is why this isn''t done automatically. VC++, for instance, does this for every C header. Remember NOT to use this for C++ headers.
Hope this helps.
To distinguish between let''s say
void some_function(int x, int y);
and
int some_function(char *string);
in C++, the compiler uses something called name mangling. Basically, it encodes parameter types into function name. Here''s an example:
?__clrscr@@YAXXZ
YAXXZ is the parameter information; in this case, there are no parameters.
Now, in C you don''t need name mangling because you can''t overload functions. Therefore, function is called ___clrscr. The compiler always adds an extra underscore in front of C function names, that has to do with calling convention.
Since clrscr is the C function, its real name is ___clrscr, not ?__clrscr@@YAXXZ. Why are you getting the latter name? That''s because C++ compiler thinks it''s a C++ function.
To fix this, add the following around #include <conio.h>:
extern "C" {#include <conio.h>}
This tells the compiler to treat functions in conio.h as C functions, which is what they are. The real puzzle to me is why this isn''t done automatically. VC++, for instance, does this for every C header. Remember NOT to use this for C++ headers.
Hope this helps.
---visit #directxdev on afternet <- not just for directx, despite the name
Why wouldn''t System("cls"); work?
"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
"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 ask myself the same thing between each "thud". (Said thud being my head against the wall).
In any event, in all honesty I would prefer something like conio.h....or anything of such a nature to work rather than calling on the system to interpret it.
BTW I ran it on 98se and XP and none of this worked...same compiler however but that doesn''t seem to make any sense given all the above...
In any event, in all honesty I would prefer something like conio.h....or anything of such a nature to work rather than calling on the system to interpret it.
BTW I ran it on 98se and XP and none of this worked...same compiler however but that doesn''t seem to make any sense given all the above...
February 20, 2002 09:02 PM
Just because you include the header file doesn''t mean you''re linking to the proper library. Search for documentation in CW on conio.h and see what library its implementation is defined in. Then make sure you''re linking to it.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement