Skip to main content
Post Closed as "Not suitable for this site" by CommunityBot
added 98 characters in body
Source Link
House
  • 73.5k
  • 17
  • 188
  • 276

I'm getting an error that says "control may reach end of function" and I have gone through my code several times now and am not spotting the error. It may be something simple too.

Blockquote

// loop continually until the user gives a valid guess

FText GetValidGuess() { EGuessStatus Status = EGuessStatus::Invalid_Status; do { // get a guess from the player int32 CurrentTry = BCGame.GetCurrentTry(); std::cout << "Try " << CurrentTry << ". Enter your guess: "; FText Guess = ""; std::getline(std::cin, Guess);

FText GetValidGuess()
{
    EGuessStatus Status = EGuessStatus::Invalid_Status;
    do {
        // get a guess from the player
        int32 CurrentTry = BCGame.GetCurrentTry();
        std::cout << "Try " << CurrentTry << ". Enter your guess: ";
        FText Guess = "";
        std::getline(std::cin, Guess);
        
        // check status and give feedback
        Status = BCGame.CheckGuessValidity(Guess);
        switch (Status) {
            case EGuessStatus::Wrong_Length:
                std::cout << "Please enter a " << BCGame.GetHiddenWordLength() << " letter word.\n";
                break;
            case EGuessStatus::Not_an_isogram:
                std::cout << "Please enter a word witout repeating letters.\n";
                break;
            case EGuessStatus::Not_Lowercase:
                std::cout << "Please enter all lowercase letters.\n";
                break;
            default:
                return Guess;
        }
        std::cout << std::endl;
    } while (Status != EGuessStatus::OK); // keep looping until we get no error
}

}

I'm getting an error that says "control may reach end of function" and I have gone through my code several times now and am not spotting the error. It may be something simple too.

Blockquote

// loop continually until the user gives a valid guess

FText GetValidGuess() { EGuessStatus Status = EGuessStatus::Invalid_Status; do { // get a guess from the player int32 CurrentTry = BCGame.GetCurrentTry(); std::cout << "Try " << CurrentTry << ". Enter your guess: "; FText Guess = ""; std::getline(std::cin, Guess);

    // check status and give feedback
    Status = BCGame.CheckGuessValidity(Guess);
    switch (Status) {
        case EGuessStatus::Wrong_Length:
            std::cout << "Please enter a " << BCGame.GetHiddenWordLength() << " letter word.\n";
            break;
        case EGuessStatus::Not_an_isogram:
            std::cout << "Please enter a word witout repeating letters.\n";
            break;
        case EGuessStatus::Not_Lowercase:
            std::cout << "Please enter all lowercase letters.\n";
            break;
        default:
            return Guess;
    }
    std::cout << std::endl;
} while (Status != EGuessStatus::OK); // keep looping until we get no error

}

I'm getting an error that says "control may reach end of function" and I have gone through my code several times now and am not spotting the error. It may be something simple too.

// loop continually until the user gives a valid guess
FText GetValidGuess()
{
    EGuessStatus Status = EGuessStatus::Invalid_Status;
    do {
        // get a guess from the player
        int32 CurrentTry = BCGame.GetCurrentTry();
        std::cout << "Try " << CurrentTry << ". Enter your guess: ";
        FText Guess = "";
        std::getline(std::cin, Guess);
        
        // check status and give feedback
        Status = BCGame.CheckGuessValidity(Guess);
        switch (Status) {
            case EGuessStatus::Wrong_Length:
                std::cout << "Please enter a " << BCGame.GetHiddenWordLength() << " letter word.\n";
                break;
            case EGuessStatus::Not_an_isogram:
                std::cout << "Please enter a word witout repeating letters.\n";
                break;
            case EGuessStatus::Not_Lowercase:
                std::cout << "Please enter all lowercase letters.\n";
                break;
            default:
                return Guess;
        }
        std::cout << std::endl;
    } while (Status != EGuessStatus::OK); // keep looping until we get no error
}
Source Link

Having trouble with EOF in Xcode

I'm getting an error that says "control may reach end of function" and I have gone through my code several times now and am not spotting the error. It may be something simple too.

Blockquote

// loop continually until the user gives a valid guess

FText GetValidGuess() { EGuessStatus Status = EGuessStatus::Invalid_Status; do { // get a guess from the player int32 CurrentTry = BCGame.GetCurrentTry(); std::cout << "Try " << CurrentTry << ". Enter your guess: "; FText Guess = ""; std::getline(std::cin, Guess);

    // check status and give feedback
    Status = BCGame.CheckGuessValidity(Guess);
    switch (Status) {
        case EGuessStatus::Wrong_Length:
            std::cout << "Please enter a " << BCGame.GetHiddenWordLength() << " letter word.\n";
            break;
        case EGuessStatus::Not_an_isogram:
            std::cout << "Please enter a word witout repeating letters.\n";
            break;
        case EGuessStatus::Not_Lowercase:
            std::cout << "Please enter all lowercase letters.\n";
            break;
        default:
            return Guess;
    }
    std::cout << std::endl;
} while (Status != EGuessStatus::OK); // keep looping until we get no error

}