Can anyone please help i need to get this finished
Can anyone please help i need to get this finished
Post your code with the errors...
I've already given you your best advice. The time you've been wasting here trying to beg for more help you could have used to do what I said, and have been done by now.
Break your program into small steps. Test each one. Combine them one at a time into a bigger program, testing as you do. There are no steps to skip there. Do it right, or don't do it at all. You don't even have to put them in their own program, but you do have to do them one at a time and test each one. There are no free passes in programming. You think about your problem, break it into steps, and test each step after you've written it before moving to the next one. Because if you do it any other way than that, it's way more work in the long run.
Quzah.
Hope is the first step on the road to disappointment.
I think i did the part good this time, but i got some dumb errors. it has missing ';' before 'type' on the side of int games and it now says numguesses is undeclared seriously what the hell?
i am making progress but it's super slow.Code:#define _CRT_SECURE_NO_DEPRECATE #include <stdio.h> #define MAXGUESSES 6 void Instructions( ); int PlayGame(char answer); char GetGuess( ); int CompareGuess(char guess, char answer); int main() { //declare additional variables char letter=0; int gamesToPlay = 0; int i = 0; FILE *inp; Instructions(); inp=fopen("guessLtrs.txt","r"); scanf(" %d",&gamesToPlay); //get c letter //open file //get number of games to play for(i=0;i<gamesToPlay;i++) { fscanf(inp," %c",&letter); GetGuess( ); //get a letter from file //Play one game //check for win or lose } fclose(inp); //close file return 0; } //this function provides instructions to the user on how to play the game void Instructions( ) { printf("Welcome to Letter Guess\n"); printf("To begin you will enter the number of games you want to play(1 – 5 games)\n"); printf("You have 6 chances to guess each letter\n"); printf("Let's begin:\n\nHow many games would you like to play? (1 - 5):"); return; } //this function prompts the player to make a guess and returns that guess //this function is called from inside the PlayGame( ) function described above char GetGuess( ) { char guess=0; printf("Enter a guess:", guess); scanf(" %c",&guess); return guess; } //this function takes two arguments, the guess from the player and the answer from the file. //It lets the user know if the guess comes alphabetically before or after the answer //The function returns 1 if the guess matches the answer and returns a 0 if they do not match int CompareGuess(char guess, char answer) { if (guess==answer) return 1; else if (guess<answer){ printf("The letter you are trying to guess comes after %c", guess); return 0; }else{ printf("The letter you are trying to guess comes before %c", guess); return 0; } //this function runs one game. It for checks either 6 incorrect guesses or correct guess. //It returns a 0 if the game is over and the player did not guess the letter, otherwise it returns 1. int PlayGame(char answer) { int numGuesses = 0; while(numGuesses < MAXGUESSES) { GetGuess( ); //get guess function call //compare guess function call //update counter for number of guesses used numGuesses = numGuesses +1; } }
Those errors your compiler spits out at you conveniently have line numbers. I wonder if you could use that somehow to figure out what line the error was on?
Oh, and you never actually use what GetGuess returns, so there's not really any point in even having that function.
Quzah.
Hope is the first step on the road to disappointment.
I know what lines the errors are on, but i see no way in fixing them
where am i supposed to put a ( in int PlayGame(char answer) i sure as hell know you don't put it on the end.
As for numguesses it has already been declared why is it sayin it is undeclared?
What do i do with getGuess then? it says i have to function call it into int playgame.
Last edited by ltdec; 10-04-2011 at 08:20 PM.
You never call compareGuess or PlayGame. START SMALL...Post your code with only your main and getGuess functions. Then print the guess in main after calling getGuess. If you can't do that I don't think there is much more help we can give you. You will need to go back and learn the basics.
If I never call compare guess or playgame why does the outline tell me to put the functions into Int Playgame?
What I'm saying is you never use that function...
Can you explain step by step i'm new to all of this.
You aren't even trying to solve this. You are just throwing code around and hoping it happens to work right. Programming doesn't typically work that way. You actually are required to think out and plan what you want to do. There are very very few people who can successfully sit down and just start writing programs from start to finish without having to stop and ponder what they want to do.
Quzah.
Hope is the first step on the road to disappointment.
I was good until this compare and greater than became involved also this is the biggest program to date i've had to do. I did not think it would be that difficult when i first started but i was dead wrong. I wont ask for help after this program I promise, Im gonna have to devote a good amount of time into programming.
can you explain how to solve those errors? even if i remove the getguess function i still get them.
Start with this...
Now send guess and letter to the compareGuess function and see if they are the same. Once you can do that let us know.
Code:#include <stdio.h> void getGuess(char* guess); int main() { char guess; char letter = 'R'; getGuess(&guess); printf("%c\n",guess); //call compareGuess return 0; } void getGuess(char* guess) { printf("Enter a char: "); scanf("%c",guess); }
He can't understand returning a value so you want him to use pointers? Him and the tic-tac-toe guy need to get together. :rofl:
Quzah.
Hope is the first step on the road to disappointment.