关闭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;
}
posted @ 2012-08-14 13:06  svking  阅读(667)  评论(0编辑  收藏  举报