Function not defined in this scope

I currently use code::blocks ide.

Today when using clrscr.

I do #include<conio.h> but it still gives error that clrscr is not defined in this scope.

I also tried using rand and srand functions but they give the same error.
rand is defined in stdlib

clrscr is non-standard
http://stackoverflow.com/questions/930138/is-clrscr-a-function-in-c
Then how do I clear the screen when need
what os are you using?
Windows XP
There are a bunch of ways of doing it. The easiest, by far, is just to print a bunch of newlines:
 
std::cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";

It's simple, you understand what it means, and it works. There are more complicated, 'proper' versions out there levering the WinAPI if you want to do it in a different way, though.

Still, why do you want to clear the screen anyway? It's normally not all that helpful, it's hard to do, and if you're making a game or something it's just much easier to do it with graphics. Nevertheless, if you're intent on clearing the screen this article has a bunch of ways to do it: http://www.cplusplus.com/articles/4z18T05o/
Last edited on
cout << string (10, '\n');
closed account (48T7M4Gy)
1
2
3
<stdlib.h>
...
system ("CLS");


Often works but beware, you will get a lot of advice not to use it for a lot of good reasons, but it is quicker, better and cheaper for class exercises than taking a hammer to the monitor when the deadline beckons or at an assessment demo.
Sounds quite simple, but what problems does it cause?
closed account (48T7M4Gy)
Try it, you won't do any damage to anything but it's not good programming practice ...

http://www.cplusplus.com/articles/j3wTURfi/
Topic archived. No new replies allowed.