关闭stdout后打开stdout
先关闭stddout,再打开stdout。
#include <stdio.h> #include <unistd.h> int main(int argc, char* argv[]) { fclose(stdout); printf("This sentence will not be printed."); freopen("/dev/tty", "w", stdout); printf("This sentence will be printed.\n"); return 0; }
Keep Looking