2017年6月12日 星期一

Week15 閻覃的上課筆記

Week15 閻覃的上課筆記.md

Week15 閻覃的上課筆記

內插公式

交叉相乘

寫檔案

 
1
#include <stdio.h>
2
FILE *fout = NULL;
3
fout = fopen("file.txt","w+");

``w+'' Open for reading and writing. The file is created if it does not exist, otherwise it is truncated. The stream is positioned at the beginning of the file.

w+模式會在每次打開檔案時丟棄上次的檔案。如果想追加可以換成a+

 
1
fprintf(fout,"....\n");

這樣在程式退出后,資料就會被寫入檔案。

如果想隨時立即寫入,需要執行以下程式碼

 
1
fflush(fout);

沒有留言:

張貼留言