Hi im kinda of a newbie in C++ but i need help... i have made a calculator and inside it a matrix effect... ex: press * for calc , press 2 for matrix... thats the output! ive made a loop for the calc and it works perfectly fine! but in the matrix i have a prob... i cant close it once opened i want a function to return me back to the main page when i press any key.. (tryed system("PAUSE") but it messed up my code ) heres the Code:
[code]
#include<iostream>
#include<math.h>
#include<conio.h>
#include<string>
#include<windows.h>
#include<ctime>
using namespace std;
void full()
{
keybd_event(VK_MENU,0x*8,0,0);
keybd_event(VK_RETURN,0x*c,0,0);
keybd_event(VK_RETURN,0x*c,KEYEVENTF_KEYUP,0);
keybd_event(VK_MENU,0x*8,KEYEVENTF_KEYUP,0);
}
void randChar() //randChar function
{
char symbol = rand()%*26+**;
cout<<symbol<<"\b";}
void randCharEnd()
{
char symbol = rand()%*26+**;
cout<<symbol;}
int spaceMaker(int a)
{
for(int i =0; i<=a; i++)
cout<<" ";}int timeWaster (int a)
{
a = a * *0;
for(int i=0; i<= a; i++)
cout<<" \b";
}
void matrix()//matrix function
{
system("COLOR 0A");
srand((unsigned)time(NULL));
int lineFeedCtr =0;
int charCtr; int clearCtr = 0; char randChar2; int ctr; int spaceCtr = 0; cout<<"M"; timeWaster(200); cout<<"I"; timeWaster(200); cout<<"N"; timeWaster(200); cout<<"A"; timeWaster(200); cout<<"'"; timeWaster(200); cout<<"S "; timeWaster(200); cout<<"C"; timeWaster(200); cout<<"R"; timeWaster(200); cout<<"E"; timeWaster(200); cout<<"A"; timeWaster(200); cout<<"T"; timeWaster(200); cout<<"I"; timeWaster(200); cout<<"O"; timeWaster(200); cout<<"N "; timeWaster(*00); cout<<"."; timeWaster(200); cout<<".."; timeWaster(200); cout<<".."; timeWaster(200); cout<<"."; timeWaster(200);
cout<<"."; timeWaster(*00); cout<<"."; timeWaster(*00); cout<<".";
timeWaster(*00); cout<<".\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"; timeWaster(*200); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randCharEnd(); timeWaster(200); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randCharEnd(); timeWaster(*75); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randCharEnd(); randCharEnd(); timeWaster(*50); randChar(); randChar(); randChar(); randChar(); randCharEnd(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); timeWaster(*25); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randCharEnd(); timeWaster(*20); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randCharEnd(); timeWaster(**0); randChar(); randChar(); randChar(); randChar(); randCharEnd(); timeWaster(*00); randChar(); randChar(); randChar(); randChar(); randCharEnd(); timeWaster(*0); randChar(); randChar(); randChar(); randChar(); randCharEnd(); timeWaster(80); randChar(); randChar(); randChar(); randChar(); randCharEnd(); timeWaster(70); randChar(); randChar(); randChar(); randChar(); randCharEnd(); timeWaster(60); randChar(); randChar(); randChar(); randChar(); randCharEnd(); timeWaster(50); randChar(); randChar(); randChar(); randChar(); randCharEnd(); timeWaster(50); randChar(); randChar(); randChar(); randChar(); randCharEnd(); timeWaster(50); randChar(); randChar(); randChar(); randChar(); randCharEnd(); timeWaster(50); randChar(); randChar(); randChar(); randChar(); randCharEnd(); timeWaster(50); randChar(); randChar(); randChar(); randChar(); randCharEnd(); timeWaster(50); randChar(); randChar(); randChar(); randChar(); randCharEnd(); timeWaster(50); randChar(); randChar(); randChar(); randChar(); randCharEnd(); timeWaster(50); randChar(); randChar(); randChar(); randChar(); randCharEnd(); timeWaster(50); randChar(); randChar(); randChar(); randChar(); randCharEnd(); timeWaster(50); randChar(); randChar(); randChar(); randChar(); randCharEnd(); timeWaster(50); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar(); randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar();randChar(); randCharEnd(); timeWaster(50); while(***7>0) { ctr = 0; charCtr = rand()%*0+5; spaceCtr = rand()%75;
if(clearCtr>=280) {
clearCtr = 0; }
while(ctr <= charCtr)
{
spaceMaker(spaceCtr);
ctr++;
randChar2 = static_cast<char>(rand()%*26+**);
cout<<randChar2<<endl;
clearCtr++;
for(int b=0; b<=200;b++)
cout<<" \b";
}
}
}
double calculator()
{
double x;
double y;
char cChar;
cin>>x>>cChar>>y;
cin.ignore();
switch (cChar)
{
case '+':
cout<<"The Answer is: "<< x << " + " << y << " = " <<(x + y) <<endl;
break;
case '-':
cout<<"The Answer is: "<< x << " - " << y << " = " <<(x - y) <<endl;
break;
case '/':
cout<<"The Answer is: "<< x << " / " << y << " = " <<(x / y) <<endl;
break;
case '*':
cout<<"The Answer is: "<< x << " * " << y << " = " <<(x * y) <<endl;
break;
case '%':
cout<<"The Answer is: "<< x << " % " << y << " = " <<(y/*00 *x) <<endl;
break;
case '^':
cout<<"The Answer is: "<< x << " ^ " << y << " = " <<pow(x , y) <<endl;
break;
}
}
int main()
{
full();
char doa;
char answer;
do{
system("CLS");
system("TITLE Mina's Calculator 2");
system("COLOR *");
cout<<" *) To Calculate Use These Signs : \n (+,-,*,/,^,%) \n \n 2) To Exit \n\n *) To Do The Matrix Effect... \n"<<endl;
timeWaster(200);timeWaster(*00);cout<<"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"<<endl;
cin>>answer;
if (answer=='*')
{
cout<<" **** U choose calculator... ****\n"<<endl;
calculator();
}
else if (answer=='2')
{
Sleep (*);
timeWaster(250);cout<<" *** Exiting in * ***"<<endl;
Sleep (2);
timeWaster(500);cout<<" *** 2 ***"<<endl;
Sleep (*);
timeWaster(500);cout<<" *** * ***"<<endl;
timeWaster (*00);
cin.get();
return 0;
}
if (answer=='*')
{
cout<<" **** U choose the Matrix Effect **** "<<endl;
matrix();
}
cout<<"would u like to restart? y or n? "<<endl;
cin>>doa;
cin.ignore();
}while (doa=='y' ||doa=='Y');
if (doa=='n' || doa=='N')
{
cout<<" *** Thanks for using my calculator *** "<<endl;
}
cin.get();
return 0;
}
[/code]
The output is a full screen console app.. so i need a function to close the matrix when i press any key (or a specific key would be better)...
add this function to my code and repost it plz :) , thanks in advance