Hi,
I'm trying to write a code for the game Stone-Scissors-Paper.
I faced some problems when it comes to announcing the winner. I get a syntax error in line 62.
I'll appreciate it if someone help me out =)
Code:
/*
* File : pss.c
* Program : Paper, stone, scissors game
* Author : Sepideh
*/
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#include<string.h>
#define MAX_TURNS 10
#define MAX_BUFFER 6
#define DRAW 0
#define COMPUTER_WIN 1
#define HUMAN_WIN 2
#define STONE 0
#define SCISSOR 1
#define PAPER 2
#define STONE_STR "stone"
#define SCISSOR_STR "scissors"
#define PAPER_STR "paper"
/* ------------------- Utilities ---------------*/
void clear_stdin();
int human_choice();
int computer_choice();
void print_computer_choice();
int winner(int human,int computer);
/***************************************************
*
* MAIN
*
***************************************************/
int main()
{
int human,
computer,
result;
/*statistic;
int i;*/
srand( time(0) );
/* statistic = 0;*/
printf("Welcome to Paper-Scissors-Stone game by Sepideh!\n");
human=human_choice();
computer=computer_choice();
print_computer_choice();
result=winner(int human,int computer);
/* Get result depending on choices */
/* Print result */
/* Update statistics */
/* Print total depending on statistics */
return 0;
}
/******************************************************
*
* DEFINITIONS
*
******************************************************/
void clear_stdin()
{
while( getchar() != '\n' ){;}
}
int human_choice()
{
char humanch[10];
int resultat;
printf("Your turn!Type your choice.\n");
scanf("%s",humanch);
while(strcmp(humanch,STONE_STR)!=0&&strcmp(humanch,SCISSOR_STR)!=0&&strcmp(humanch,PAPER_STR)!=0){
printf("Wrong entry! Try again.\n");
scanf("%s",humanch);
}
if(humanch=="stone")
resultat=0;
if(humanch=="scissors")
resultat=1;
if(humanch=="paper")
resultat=2;
return resultat;
void clear_stdin();
}
int computer_choice()
{
int slumptal;
slumptal = rand()%3;
return slumptal;
printf("%d",slumptal);
}
void print_computer_choice(){
int slumptal;
if(slumptal==0)
printf("stone\n");
if(slumptal==1)
printf("scissors\n");
if(slumptal==2)
printf("paper\n");
}
int winner(int human,int computer)
{
int winresult;
if(human_choice()==computer_choice())
winresult=0;
if((human_choice()==0&&computer_choice()==1)||(human_choice()==1&&computer_choice()==2)||(human_choice()==2&&computer_choice()==2))
winresult=2;
return winresult;
/* printf("%d",winresult);*/
}