Here is a program. Its only purpose is to delete the line printed, after some user input.
main.cpp
#include <iostream>
#define ESC_PREV_LINE "\e[F"
#define ESC_CLEAR_TO_END "\e[K"
int main(){
int i;
std::cerr << "Some input to clear: " << std::flush;
std:: cin >> i;
std::cerr << ESC_PREV_LINE ESC_CLEAR_TO_END << std::flush;
}
Inside Xcode, if the user were to input 2
, this is the output:
Some input to clear: 2
[F[KProgram ended with exit code: 0
If compiled in terminal, using: g++ -std=c++20 main.cpp -o test
, the output is cleared after user input, right before the program exists, and the shell looks like the program never ran.
How can I include this functionality within Xcode? I am writing a program that requires it, but developing inside Xcode, and it would be highly inconvenient to have to swap to the terminal just to test my program output.