C stdio fputs() 函式
示例
將字串寫入檔案
FILE *fptr;
// 開啟檔案以寫入模式
fptr = fopen("filename.txt", "w");
// 將字串寫入檔案
fputs("Hello World!", fptr);
fclose(fptr);
定義和用法
fputs()
函式將一個字串寫入檔案。
fputs()
函式定義在 <stdio.h>
標頭檔案中。
語法
fputs(const char * str, FILE * fptr);
引數值
引數 | 描述 |
---|---|
str | 必需。一個包含要寫入字串的 char 陣列。 |
fptr | 必需。一個檔案指標,通常由 fopen() 函式建立。 |
技術詳情
返回 | 一個非負的 int 值,表示函式成功執行。如果發生錯誤,它將返回常量 EOF 。 |
---|