lundi 16 septembre 2019

adding valid user input into character array

So I'm trying to add an array called char usersAnswers[10] which holds up to 10 answers as there are only 10 rounds in my game. My struggle is finding a way to implement every valid answer the user gives into that array. I was thinking of adding a for loop below the second if statement and doing something like usersAnswers[i] = userInput but I wasn't sure. Any help would be appreicated.

    if(numberofCharacters == 3){
        if((answerValid(userInput))){
            numberofAnswers += 1;
        }else{
            printf("Please try again. \n");
        }
    }else{
        printf("Only enter 3 characters. \n");
    }

Aucun commentaire:

Enregistrer un commentaire