Trying to make a loop here but it just spilled the f*&% all over my screen.
The skeleton of the game should be something like:
int main() {
bool next = false;
do {
const std::string target = get_str_digits(std::cout, std::cin);
std::string guess;
do {
parse_guess(std::cout, std::cin, guess);
} while (not check_guess(std::cerr, target, guess));
std::cout << "Do you want to play another game? (y/N) ";
char check;
std::cin >> check;
next = (check == 'y' or check == 'Y');
} while (next);
return 0;
}
Here, by get_str_digits, you get a four-digit number in std::string; by parse_guess, you get a four-digit number guess result; by check_guess, you compare target and guess, put the result in std::cerr and return false if failed otherwise true to break the inner loop.
Now, it's your work to implement these three functions.
BTW, here the assumption lies, that you store the target and guess in std::string. Of course you might use other type to store and compare them.