Jump to content
XaFlaForo

Spot the coding mistake

Recommended Posts

Let's see if anyone who has the interest to learn c++ can spot the mistake

#include <iostream>
#include <string>

void PrintIntro();
std::string GetGuessAndPrintBack();

using FText = std::string;
using int32 = int;

bol answer_correct = false;

int main() {
    
    PrintIntro();
    
    GetGuessAndPrintBack();
    
    std::cout << std::endl;
    return 0;
}

void PrintIntro() {
    
    //--- Introduce the game
    constexpr int WORD_LENGHT = 5;
    std::cout << "Welcome to bulls and cows." << std::endl;
    std::cout << "Can you guess the " << WORD_LENGHT << " letter isogram?" << std::endl;
    return;
}

std::string GetGuessAndPrintBack() {
    
    //--- Get a guess from the player
    FText Guess = "";
    std::cout << "ENTER YOUR GUESS: ";
    std::getline(std::cin, Guess);
    
    //--- Prints the guess
    std::cout << "Your guess was:" << Guess << std::endl;

    return Guess;
}

 

Edited by XaFlaForo

Share this post


Link to post
Share on other sites
12 hours ago, XaFlaForo said:

Let's see if anyone who has the interest to learn c++ can spot the mistake

void PrintIntro() {
    
    //--- Introduce the game
    constexpr int WORD_LENGHT = 5;
    std::cout << "Welcome to bulls and cows." << std::endl;
    std::cout << "Can you guess the " << WORD_LENGHT << " letter isogram?" << std::endl;
    return;
}

 

What about the horrible misspelling of "WORD_LENGHT"? It wouldn't error it, but it's gotta be worth some points. 😂

Share this post


Link to post
Share on other sites
18 hours ago, XaFlaForo said:

 

#include <iostream>
#include <string>

void PrintIntro();
std::string GetGuessAndPrintBack();

using FText = std::string;
using int32 = int;

bol answer_correct = false;

int main() {
    
    PrintIntro();
    
    GetGuessAndPrintBack();
    
    std::cout << std::endl;
    return 0;
}

void PrintIntro() {
    
    //--- Introduce the game
    constexpr int WORD_LENGHT = 5;
    std::cout << "Welcome to bulls and cows." << std::endl;
    std::cout << "Can you guess the " << WORD_LENGHT << " letter isogram?" << std::endl;
    return;
}

std::string GetGuessAndPrintBack() {
    
    //--- Get a guess from the player
    FText Guess = "";
    std::cout << "ENTER YOUR GUESS: ";
    std::getline(std::cin, Guess);
    
    //--- Prints the guess
    std::cout << "Your guess was:" << Guess << std::endl;

    return Guess;
}

 

here's the mistake

Edited by BoGuu
  • Haha 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×