is thaere a cls in c++?
Feb 17, 2016 at 8:37pm UTC
ok im making a program to calculat high values and have user in put for my first disign but i want to clear the terminall on the menu and system("cls") dont work
here is my code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int showfar =0;
int addnext =0;
int hexin= 0;
int binaryin= 0;
int pause= 0;
void eng(){
int inputa = 0;
topeng:
for (int cls = 0; cls < 310; cls ++)
std::cout << "\n" ;
cout << "hello and welcome to the calculator menu" << endl;
cout << "number so far:" << showfar << endl;
cout << "1- for adding " << endl;
cout << "2- for number to hex" << endl;
cout << "3- for number to binary max 1023" << endl;
cout << "4- to exit" << endl;
std::cin >> inputa;
if (inputa== 1){goto simple1;}
if (inputa== 2){goto hexindex;}
if (inputa== 3){goto binaryindex;}
if (inputa== 4){goto exit;}
simple1:
// this is the adding section--------------------------------------------------------------------------
agen1:
cout << showfar << endl;
cout << "add 0 to go back" << endl;
cout << "(adding) next num plz" << endl;
cin >> addnext;
if (addnext == 0){goto topeng;}
showfar=showfar+addnext;
goto agen1;
hexindex:
agen2:
cout << "enter num to turn into hex" << endl;
cout << "enter 0 to go back" << endl;
cin >> hexin;
if (hexin == 0){goto topeng;}
std::cout << std::hex << hexin << '\n' ;
goto agen2;
binaryindex:
agen3:
long dec,rem,i,sum;
i=1;
sum=0;
cout<<"Enter the num to be converted:" ;
cout<<"enter 0 to go back" <<endl;
cin>>dec;
if (dec== 0){goto topeng;}
do
{
rem=dec%2;
sum=sum + (i*rem);
dec=dec/2;
i=i*10;
}while (dec>0);
cout<<"The binary of the given number is:" <<sum<<endl;
cin>>pause;
if (pause == 0){goto topeng;}
goto agen3;
exit:
cout << "goodbye" << endl;
}
int main()
{
int lang = 0;
cout << "1-eng" << endl;
cout << "2-deu" << endl;
cin >> lang;
if (lang== 1){
eng();
return 0;
}
return 0;
}
if you can help that woaled be nice
Feb 17, 2016 at 8:40pm UTC
C++ Doesn't know the concept of a console, so you can't using pure C++.
Feb 17, 2016 at 9:36pm UTC
With any luck, your console will recognize the ANSI escape sequences:
http://ascii-table.com/ansi-escape-sequences-vt-100.php
You can use one sequence to clear the screen and another to move the cursor to the top left:
1 2 3 4 5 6 7 8 9 10 11 12
#include<iostream>
// In the strings below, \033 is the escape character.
constexpr char clearScreen[] = "\033[2J" ;
constexpr char topLeft[] = "\033[;H" ;
int
main(void )
{
std::cout << clearScreen << topLeft;
return 0;
}
Topic archived. No new replies allowed.