@louiscouture I think this should do it:
g++ source.cpp && /.a > output.txt
@louiscouture correction this works:
g++ source.cpp && ./a.out > output.txt
I.e you compile and execute the program but redirect output to the text file.
@louiscouture just run the binary like you would run any other executable and redirect output to a file.
e.g., ./a.out > b.txt
@louiscouture
g++ -o <name-you-want-to-give> source.cpp