{
int max, death;
string black = "/roll";
{
cout<< " Welcome to the dice rolling game\n";
cout<< "\n";
cout<< "To roll the dice simply type /roll\n";
cout<< "\n";
cout<< "\n";
cin>> black;
cout<< "\n";
cout<< "\n";
cin.ignore ();
if (black == "/roll")
{
srand (time (0));
death = (rand () % 20 );
cout<< "\n";
cout<< "\n";
cout<< "You rolled a .... " << death << "\n";
cout<< "\n";
}
cin.ignore ();
cin.get ();
}
}
Its a simply program, I' am jus wondering how I would clear the screen back to the beginning of the program and not just clearing everything to a blank screen.
As Hanst said, C++ doesn't provide console functionality, it's the OS that provides the functionality. If you don't care about cross-platform development (for consoles), go ahead an use system( "CLS" ). However! a call to system( ) is heavy, ugly and is a security risk; not to mention that it relies on the executables within the System32 folder. A removal of the executable that your program uses, and your program will not run.
It calls whatever program you tell it to, as Framework said. Someone could easily replace that program with a malicious one, or even simply place it higher on the default paths the OS looks on.