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 pointer
FILE *f;
char ch;
//Create the file for write operation
f=fopen("includehelp.txt","w");
printf("Enter five character\n");
for(int i=0;i<5;i++){//take the characters from the users
scanf("%c",&ch);
//write back to the file
putc(ch,f);
//clear the stdin stream buffer
fflush(stdin);
}
//close the file after write operation is over
fclose(f);
//open a file
f=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 characters
printf("%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()函数与示例相关推荐

  1. merge函数_c语言中的merge函数

    展开全部 merge()是C++标准库的函数,主要实现函数的排序和合并,不仅仅是合并,具体要求参e5a48de588b63231313335323631343130323136353331333431 ...

  2. c语言中的printf函数_C语言中的printf()函数与示例

    c语言中的printf函数 C语言中的printf()函数 (printf() function in C) The printf() function is defined in the <s ...

  3. c语言putchar函数_C语言中的putchar()函数与示例

    c语言putchar函数 C语言中的putchar()函数 (putchar() function in C) The putchar() function is defined in the < ...

  4. c语言的point函数,C语言中friend友元函数详细解析

    C语言中friend友元函数详细解析 友元函数是可以直接访问类的私有成员的非成员函数.它是定义在类外的普通函数,它不属于任何类,但需要在类的定义中加以声明,声明时只需在友元的名称前加上关键字frien ...

  5. c语言其他函数调用main函数,C语言中的main函数以及main函数是如何被调用的

    main函数是C语言中比较特殊的函数,C程序总是从main函数开始执行,main函数的原型是: int main(int argc, char *argv[]); 其中argc是命令行参数的个数,ar ...

  6. c语言中rewind函数_C语言中的rewind()函数与示例

    c语言中rewind函数 C中的rewind()函数 (rewind() function in C) The rewind() function is defined in the <stdi ...

  7. c++isdigit函数_c++isdigit函数_C语言中isdigit()函数和isxdigit()函数的用法

    C语言isdigit()函数:判断字符是否为阿拉伯数字头文件: #include 定义函数: int isdigit(int c); 函数说明:检查参数 c 是否为阿拉伯数字0 到9. 返回值:若参数 ...

  8. c++isdigit函数_C语言中isdigit()函数和isxdigit()函数的用法

    C语言isdigit()函数:判断字符是否为阿拉伯数字头文件: #include 定义函数: int isdigit(int c); 函数说明:检查参数 c 是否为阿拉伯数字0 到9. 返回值:若参数 ...

  9. c语言中什么函数可以作为虚函数,C++语言中的“虚函数”就像C语言中的指针,必须要弄懂的...

    上一节较为详细的讨论了C++语言中基类被派生类继承过程中的内存模型,尤其较为详细的分析了虚函数及其虚表.虚表指针在内存中是如何分布,如何存储的,这对于理解C++语言中的"动态绑定" ...

最新文章

  1. 后序遍历的非递归算法python_刷题系列 - Python用非递归实现二叉树后续遍历
  2. 9月9日项目群管理活动讨论
  3. 外国人居留证申请程序
  4. iOS中代码支持多国语言切换的实现(Xcode5+iOS7)
  5. 你是第几名:Excel 中 Large 和 Small 的用法
  6. 栈/队列 互相模拟实现
  7. A Filter of Java URL Encoding: GetQueryStringEn...
  8. php mysql搜索包含数据查询慢,php – 在mysql中搜索关键字并获取至少包含5个关键字的数据...
  9. 转!!URL和URI区别
  10. 算法48---原子的数量【栈】
  11. 快解析 : 管家婆A8远程访问解决方案
  12. 万字拆解孩子王:充满矛盾的母婴零售之王
  13. 树莓派python界面编程_树莓派PythonGUI学习
  14. oracle 11203 ora32701,love wife love life —Roger的Oracle/MySQL数据恢复博客
  15. 全国DNS服务器地址备忘录
  16. 常识:大白话讲解「对账」
  17. 活体检测论文笔记2——Deep Spatial Gradient and Temporal Depth Learning for Face Anti-spoofing
  18. 3DMax基础:渲染的小技巧(做好笔记!)
  19. 杭电ACM(HDUOJ)试题分类
  20. vue 预览、下载pdf

热门文章

  1. 表字段顺序有何影响_「品味保定」炸烹虾段乾隆赞 百年保定柔雅香
  2. 配置文件bashrc与profile的区别
  3. 创造型模式——单例模式
  4. 5-Dockerfile文件
  5. Microsoft BizTalk ESB Toolkit 2.0
  6. Facebook也大干新闻聚合 “新闻快读”向所有媒体开放
  7. vs运行时候冒了这个错:无法启动IIS Express Web 服务器~Win10
  8. kindeditor图片批量上传失败问题
  9. 解决wordpress无法离线发布(远程发布)的故障
  10. windowsXP/7下消除快捷键箭头的方法