重定向printf,輸出到文件里
FILE* fp = 0;
if(0 == ( fp = freopen("OUT.txt", "w" ,stdout)))
printf("Cannot open file.\n");
printf(“test data to file\n”);
fclose(fp);
posted on 2012-07-20 15:46 肥仔 閱讀(7597) 評(píng)論(3) 編輯 收藏 引用 所屬分類: C++ 基礎(chǔ)
隨筆 - 1469, 文章 - 0, 評(píng)論 - 661, 引用 - 0
|
||
重定向printf,輸出到文件里FILE* fp = 0;
printf(“test data to file\n”);
fclose(fp); posted on 2012-07-20 15:46 肥仔 閱讀(7597) 評(píng)論(3) 編輯 收藏 引用 所屬分類: C++ 基礎(chǔ) 評(píng)論# re: 重定向printf,輸出到文件里[未登錄](méi) 回復(fù) 更多評(píng)論很有意思,不過(guò)輸出到文件里,用戶就看不到提示信息了
2012-11-08 14:45 | 歲月漫步
# re: 重定向printf,輸出到文件里 回復(fù) 更多評(píng)論printf(“test data to file\n”);換成 perror或者fprintf(stderr ...
2012-12-19 23:58 | wysaid
# re: 重定向printf,輸出到文件里 回復(fù) 更多評(píng)論學(xué)習(xí)了,謝謝
2013-10-03 15:56 | 無(wú)香魚(yú)
|
||||||||||||||||||||||