This is a command-line implementation of the classic Rock, Paper, Scissors game in C. The game allows a user to play against the computer, with randomized computer choices and dynamic scoring.
- Cross-platform compatibility (Windows and Unix-based systems).
- Simple menu-driven gameplay.
- Keeps track of the user's and the computer's scores.
- Dynamic input handling using
getch()
or a platform-specific implementation.
- Run the program from a terminal or command prompt.
- Enter:
0
for Rock.1
for Paper.2
for Scissors.9
to exit the game.
- View the result of each round, including your choice and the computer's choice.
- At the end of the game, see your final score compared to the computer's.
- Open a terminal or command prompt.
- Compile the code using GCC or any other C compiler:
gcc rock_paper_scissors.c -o rock_paper_scissors
- Run the program:
./rock_paper_scissors
- The program uses a custom implementation of
getch()
via thetermios.h
library for character input. - Ensure that your system supports
termios.h
.
Randomized Computer Choice: The computer's choice is generated using:
srand(time(0));
com_in = rand() % 3;
Error Handling: Invalid input is handled with descriptive error messages:
fprintf(stderr, "An error occurred: %s\n", "Invalid input");
- Add a graphical interface or web version.
- Implement additional features like streak tracking or advanced rules.