C語言庫函數 int fputs(const char *str, FILE *stream) 將一個字串寫入指定的流,但不包括空字元。
聲明
以下是聲明 fputs() 函數。
int fputs(const char *str, FILE *stream)
參數
-
str -- 這是一個數組,包含null結尾的要寫入的字元序列。
-
stream -- 這是一個檔對象的標識字串將被寫入流的指針。
返回值
這個函數返回一個非負的值,否則,錯誤返回EOF。
例子
下麵的例子顯示的使用fputs() 函數。
#include <stdio.h> int main () { FILE *fp; fp = fopen("file.txt", "w+"); fputs("This is c programming.", fp); fputs("This is a system programming language.", fp); fclose(fp); return(0); }
讓我們編譯和運行上面的程式,這將創建一個檔file.txt 以下內容:
This is c programming.This is a system programming language.
上一篇:
fputc() - C語言庫函數
下一篇:
getc() - C語言庫函數