日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

putc函数_C语言中的putc()函数与示例

發布時間:2025/3/11 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 putc函数_C语言中的putc()函数与示例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

putc函數

C語言中的putc()函數 (putc() function in C)

The putc() function is defined in the <stdio.h> header file.

putc()函數在<stdio.h>頭文件中定義。

Prototype:

原型:

int putc(const char ch, FILE *filename);

Parameters: const char ch, FILE *filename

參數: const char ch,FILE *文件名

Return type: int

返回類型: int

Use of function:

使用功能:

In the file handling, through the putc() function, we write the character from the stdin to the input file stream and increments the file position pointer. The prototype of the function putc() is int putc(const char* string, FILE *filename);

在文件處理中,通過putc()函數 ,我們將來自stdin的字符寫入輸入文件流,并遞增文件位置指針。 函數putc()的原型是int putc(const char * string,FILE * filename);

It returns an integer value which is conversion of an unsigned char. It also returns EOF, if an error occurs. Whenever there is a binary file check for error with the function ferror()

它返回一個整數值,該值是無符號字符的轉換。 如果發生錯誤,它也會返回EOF 。 每當有二進制文件時,使用函數ferror()檢查錯誤

C語言中的putc()示例 (putc() example in C)

#include <stdio.h> #include <stdlib.h>int main(){//Initialize the file pointerFILE *f;char ch;//Create the file for write operationf=fopen("includehelp.txt","w");printf("Enter five character\n");for(int i=0;i<5;i++){//take the characters from the usersscanf("%c",&ch);//write back to the fileputc(ch,f);//clear the stdin stream bufferfflush(stdin);}//close the file after write operation is overfclose(f);//open a filef=fopen("includehelp.txt","r");printf("Write operation is over and file is reday for read operation\n");printf("\n...............print the characters..............\n\n");while(!feof(f)){//takes the characters in the character array ch=getc(f);//and print the charactersprintf("%c\n",ch);}fclose(f);return 0; }

Output

輸出量

翻譯自: https://www.includehelp.com/c-programs/putc-function-in-c-language-with-example.aspx

putc函數

總結

以上是生活随笔為你收集整理的putc函数_C语言中的putc()函数与示例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。