Input will be only lowercase #1
This commit is contained in:
10
hangman.c
10
hangman.c
@@ -2,6 +2,7 @@
|
||||
#include "hangman.h"
|
||||
#include <stdlib.h> //atexit
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
int main(void) {
|
||||
/* Initialization */
|
||||
@@ -50,6 +51,7 @@ void initGuessWord(game_state *gs) {
|
||||
int i;
|
||||
mvprintw(1, 1, "Please enter your word: ");
|
||||
getstr(gs->guessWord);
|
||||
toLowerCase(gs->guessWord);
|
||||
gs->wordLength = strlen(gs->guessWord);
|
||||
for (i = 0; i < gs->wordLength; i++) {
|
||||
if (gs->guessWord[i] == ' ') { //Check for spaces if it's a sentence
|
||||
@@ -61,6 +63,14 @@ void initGuessWord(game_state *gs) {
|
||||
clear(); //clear the screen
|
||||
}
|
||||
|
||||
void toLowerCase(char *str) {
|
||||
int length = strlen(str);
|
||||
int i;
|
||||
for (i = 0; i < length; i++) {
|
||||
str[i] = tolower(str[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void drawGuessWord(game_state *gs) {
|
||||
int startpos = gs->centerx - gs->wordLength;
|
||||
int i, wordpos = 0;
|
||||
|
@@ -33,3 +33,4 @@ int fillCurrentWord(game_state *gs, char validchar);
|
||||
int stackWrongCharacter(game_state *gs, char wrongchar);
|
||||
int checkWin(game_state *gs);
|
||||
void printGameStats(game_state *gs);
|
||||
void toLowerCase(char *str);
|
||||
|
Reference in New Issue
Block a user