#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int p;
int ai;
/* int '0' = "Rock";
int '1' = "Paper";
int '2' = "Scissors";*/
printf("\n\t\t\tROCK PAPER SCISSORS GAME\n\n");
printf("Enter a number (0 for Rock, 1 for Paper, 2 for Scissors): ");
scanf("%d", &p);
srand ( time(NULL) );
ai = rand()%3;
switch(p)
{
case 0: printf("\n\t\t\tYou've chosen Rock\n");
sleep(2);
printf("\n\t\t\tCOMP have chosen %d\n", ai);
if(ai==0)
{
printf("\n%36s","DRAW!!");break;
}else if(ai==2)
{
printf("\n%38s","You Win!");break;
}else if(ai==1){
printf("\n%37s","You Lose!");break;
}
case 1: printf("\n\t\t\tYou've chosen Paper\n");
sleep(2);
printf("\n\t\t\tCOMP have chosen %d\n", ai);
if(ai==1)
{
printf("\n%36s","DRAW!!");break;
}else if(ai==0)
{
printf("\n%38s","You Win!");break;
}else if(ai==2){
printf("\n%37s","You Lose!");break;
}
case 2: printf("\n\t\t\tYou've chosen Scissors\n");
sleep(2);
printf("\n\t\t\tCOMP have chosen %d\n", ai);
if(ai==2)
{
printf("\n%36s","DRAW!!");break;
}else if(ai==1)
{
printf("\n%38s","You Win!");break;
}else if(ai==0){
printf("\n%37s","You Lose!");break;
}
}
}
does anyone know how to fix this?..it’s a Rock Paper Scissors game that I made…by the way…im using windows…and I’m using sublime text 3 to compile it…
EDIT : it is solved by adding #include <windows.h>
and capitalizing the “s” in “sleep”