Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone help me, i'm having troubles with a Hangman program on C++ where there seems to be occuring some errors: - in the first

Can someone help me, i'm having troubles with a Hangman program on C++ where there seems to be occuring some errors:
- in the first photo, I have this: no operator ">>" matches these operands
- in the second photo I have this: identifier "turns" is undefined
- in the third photo I have this: expected a declararion on: }while(fg == 'y' || fg == 'Y');
If someone can create the program and fix the errors and post ir here this will be really helpful.
image text in transcribed
image text in transcribed
image text in transcribed
O play0 dangman e#include #includecfstream> #includecstring.h> #includectime.h> using namespace std; Bclass Hangman private: string word; public: //function to read a word from the file void readFile() ifstream fin; fin.open("words.txt"); if (!fin.is_open()) {( cout "File not open" > arr[i]; srand (time(0)); int i - rand(() % 10; word - arr[i]; fin.close(); //function to play Hangman void play() { //variable declaration int i, n, turn- 5, guessNo - e; char str[5], starwd[5], guesswd [5], wl, 1, fg = e; //create the star word for (i = 0; str[i] != '\'; i++) starwd[i] - *'; strcpy(str, word.c_str()); starwd[i] = '\'; //start play cout "Ready to start! The word is:" > wl; 1/check if word if (wl -- (,M. //prompt user to enter to guess the word cout "What is your guessed word?: "; //read the choice word cin >> guesswd; //check if equal with the word if (!strcmp(str, guesswd))fg = 1; //break; else if (wl -- 'l') //prompt user to enter to guess the letter cout "What letter have you chosen?: "; //read the choice cin >> 1; fg - 0; //change the star word for (i = 0; i > fg; printf(" * * "); return 0; wbile (fg 'y' || fg=='Y')

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions