Function not defined in this scope

Jun 10, 2016 at 5:22pm
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.
Jun 10, 2016 at 5:24pm
rand is defined in stdlib

clrscr is non-standard
http://stackoverflow.com/questions/930138/is-clrscr-a-function-in-c
Jun 10, 2016 at 5:55pm
Then how do I clear the screen when need
Jun 10, 2016 at 5:58pm
what os are you using?
Jun 11, 2016 at 1:47am
Windows XP
Jun 11, 2016 at 4:16am
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 Jun 11, 2016 at 4:17am
Jun 11, 2016 at 5:41am
cout << string (10, '\n');
Jun 11, 2016 at 10:27am
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.
Jun 11, 2016 at 11:34am
Sounds quite simple, but what problems does it cause?
Jun 11, 2016 at 12:08pm
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.