In C++, you can make a very simple REPL that is superior to the one in the OP in almost every way.
#include <iostream>
#include <string>
int main() {
std::string input;
while (true) {
std::cout << "> ";
std::getline(std::cin, input);
if(input == "exit") {
return EXIT_SUCCESS;
} else {
std::cout << "Unrecognized command: " << input << '\n';
}
}
}
Code quoted from “Setting Up A Better REPL” (https://mikeloomisgg.github.io/2019-04-10-set-up-repl/). It offers good insight into why C is bad in light of the alternatives like Rust and C++.