/***************************************************\
* This program imagery dice rolling *
* Write by : saeid asaadian *
* Create date : 11 - 14 - 2015 *
* Version : 1.0 *
\***************************************************/
#include <iostream>
#include "conio.h"
#include <ctime>
#include <cstdlib>
#define random(x)(rand()%x)
#define randomize()(srand(time(0)))
using namespace std;
int main()
{
cout << "Please press ENTER to roll the dice and press ESC for exit .";
do
{
char ch = getchar();
if (ch = 13)
{
system("cls");
randomize();
switch (random(6) + 1)
{
case 1:
cout << "The dice is 1";
break;
case 2:
cout << "The dice is 2";
break;
case 3:
cout <<"The dice is 3";
break;
case 4:
cout << "The dice is 4";
break;
case 5:
cout << "The dice is 5";
break;
default:
cout << "The dice is 6";
} //end of switch
} //end of if
else
if (ch = 27)
break;
} while (1); //end of do.while
return 0;
}
thing's work fine but at the end of this code i write else if statement to exit the program when user press esc key but when user press that key nothing's happen !!!! what's my mistake ??? i write this code in visual studio 2013.