按行方式寫入檔案 fputs函式

2021-10-19 12:15:28 字數 850 閱讀 7842

fputs() 函式也是用來顯示字串的,它的原型是:

函式原型:

int fputs(const char *s, file *stream);

s 代表要輸出的字串的首位址,可以是字元陣列名或字元指標變數名。

stream 表示向何種流中輸出,可以是標準輸出流 stdout,也可以是檔案流。標準輸出流即螢幕輸出,printf 其實也是向標準輸出流中輸出的。

fputs() 和 puts() 有兩個小區別:

1.puts() 只能向標準輸出流輸出,而 fputs() 可以向任何流輸出。

2.使用 puts() 時,系統會在自動在其後新增換行符;而使用 fputs() 時,系統不會自動新增換行符。

#define _crt_secure_no_warnings

#include

#include

#include

//按行向檔案寫入

python 按行讀取並判斷按行寫入檔案

f open description opinion.json w encoding utf 8 forline inopen test1set raw search.test1.json encoding utf 8 if question type description fact or opi...

檔案I O函式 fputs 函式

描述 c 庫函式int fputs const char str,file stream 把字串寫入到指定的流stream中,但不包括空字元。宣告 int fputs const char str,file stream 引數 返回值 該函式返回乙個非負值,如果發生錯誤則返回 eof。用法 incl...

檔案I O函式 fputs 函式

描述 c庫函式int fputs const char str,file stream 把字串寫入到指定的流stream中,但不包括空字元。宣告 int fputs const char str,file stream 引數 返回值 該函式返回乙個非負值,如果發生錯誤則返回eof。用法 includ...