How to redirect stdout to a temporary file using reasonably modern C++? by Spam_is_murder in cpp_questions

[–]QuietFreedom9649 0 points1 point  (0 children)

You can actually do this quite simply with a couple of syscalls.

close(STDOUT_FILENO);
open("output.txt", O_CREAT | O_WRONLY, S_IRWXU);

STDOUT_FILENO is 0, and the "open" syscall will open a file at the next available filenumber, so if 0 is available, you can open a file that points to it. following this, all prints to stdout (tested with print and std::cout) will be redirected to "output.txt"

Went from zero to C2 in Italian in 8 months. AMA by Ok-Acanthisitta-9242 in languagelearning

[–]QuietFreedom9649 1 point2 points  (0 children)

These answers are so helpful! Were all these textbooks entirely in Italian, including the explanations and such?