Clear console and "press any key to continue" functions

Hi everybody, I'm trying to write a little program with some switch statements. I wanted to make a clean and neat menu interface (yeah I know, useless..) by cleaning the console every time the case ends and waiting the user to press a key to continue, but I'm having some troubles. Does exist any function in some library which can do this easily?

Now here's what I tried. The getch and clrscr functions won't work, when compiling it keeps asking to declare them. I tried with system("cls") but still it doesn't compile (I'm not even sure about syntax). I've also tried to use cin.get() for the any key part but it doesn't really do something..

Also, I read that this conio.h is a old non-standard header library, but I'm not really sure of what this means.

1
2
3
4
5
6
7
8
9
#include <iostream>
#include <conio.h>
  case 1: {

	cout << "Press a key to continue..." << endl;
	getch();
        clrscr();
	break;
        }


Thank you for your time and have a good day.
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include<iostream>

int main()
{

   char op;
   
swith (op)
{
case 1:
   std::cout<<"Press any key to continue ........" <<endl;
default :
  std::cout<<"Invalid entry"<<endl;
}

cin.get();
cin.ignore();

return 0;
}
Last edited on
Topic archived. No new replies allowed.