Okay so I have completed this assignment after clarification that I could have hardcoded the "secret letter", but before that I was trying to use rand and this is what I have:
#include "stdio.h"
#include "stdlib.h"
#include "conio.h"
#include "time.h"
void main()
{
int min = 97;
int random = rand() % 25;
int letter = min + random;
bool correct = false;
srand(time(NULL));
do{
printf("Please enter in your guess in lower case: \n");
char guess = getch();
if(putchar(letter) == guess)
{
printf("That's correct!");
correct = true;
}
printf("\n");
}while(putchar(letter) != true);
}
I am wondering what I could have done to make this code work instead of hardcoding what I used after talking with the professor about how he wanted us to do this.
Question
Terabojin
Okay so I have completed this assignment after clarification that I could have hardcoded the "secret letter", but before that I was trying to use rand and this is what I have:
I am wondering what I could have done to make this code work instead of hardcoding what I used after talking with the professor about how he wanted us to do this.
Link to comment
Share on other sites
8 answers to this question
Recommended Posts