c语言getc函数

C语言中的getc()函数 (getc() function in C)

Prototype:

原型:

    int getc(FILE *filename);

Parameters:

参数:

    FILE *filename

Return type: int

返回类型: int

Use of function:

使用功能:

In the file handling, through the getc() function we take the next character from the input file stream and increment the file position pointer. The prototype of the function getc() is:

在文件处理中,通过getc()函数,我们从输入文件流中获取下一个字符,并递增文件位置指针。 函数getc()的原型为:

    int getc(FILE *filename);

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

它返回一个整数值,该值是无符号char的转换。 它还返回EOF ,它本身也是一个整数值。 只要有二进制文件,请使用feof()函数检查EOF 。

C语言中的getc()示例 (getc() 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 ready 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/getc-function-in-c-language-with-example.aspx

c语言getc函数

c语言getc函数_C语言中的getc()函数与示例相关推荐

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

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

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

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

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

    putc函数 C语言中的putc()函数 (putc() function in C) The putc() function is defined in the <stdio.h> he ...

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

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

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

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

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

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

  7. c语言 access编程,C语言中access/_access函数的使用实例详解

    在Linux下,access函数的声明在文件中,声明如下: int access(const char *pathname, int mode); access函数用来判断指定的文件或目录是否存在(F ...

  8. c语言指数函数除了pow,用c语言写指数函数 C语言中的POW函数怎么使用

    C语言中的POW函数使用: #include #defineACCURACY100 doublefunc1(doublet,intn); doublefunc2(doubleb,intn); doub ...

  9. c语言 recv_sin,C++_C语言中经socket接收数据的相关函数详解,recv()函数: 头文件:#incl - phpStudy...

    C语言中经socket接收数据的相关函数详解 recv()函数:头文件: #include #include 定义函数: int recv(int s, void *buf, int len, uns ...

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

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

最新文章

  1. python 迭代器 生成器 解析
  2. 安装卸载功能 [测试思路]
  3. mycncart操作使用教程 - 横幅广告
  4. JAVA程序设计----多线程(下)
  5. IdentityServer4系列 | 支持数据持久化
  6. [大学回忆录-思想]找工作:也谈谈我的专业技能
  7. chapter8.1、面向对象
  8. python字符串重复元素的删除_python删除列表重复元素
  9. typora免费将图片上传到CSDN
  10. Android版本与SDK 版本对应关系
  11. 刘强东带到石头村什么宝贝?飞翔鸽、“村长刘”品牌、歌唱家!
  12. 使用PYthon绘制小狗狗来讨 girl friend 喜欢
  13. C语言实现单链表头插法
  14. 扑克洗牌(乱数排列)
  15. 融云一站式「云市场」上线,携手生态伙伴,共建价值平台
  16. POI导出Excel(二)
  17. 跟开涛老师学shiro -- 授权
  18. 问题 A: 找x--《算法笔记》
  19. 戴尔科技云平台赋能“新基建”,打造云底座
  20. 千亿级平台技术架构:为了支撑高并发,我把身份证存到了JS里

热门文章

  1. 华人的旗帜——首位亚裔图灵奖获得者姚期智
  2. Java小白 学习笔记(三)——面向对象
  3. 1.CPU体系架构-RISC指令集和CISC指令集
  4. 我为什么不看好微信小程序_0
  5. 数据治理系列:数据血缘关系
  6. 数据血缘关系图 工具_面向数据字段的血缘关系
  7. 开源的微信公众号管理工具
  8. Xcelsius调用Webservice实例
  9. 4227. 【五校联考3day2】B (Standard IO)
  10. windows虚拟机dhcp服务器,无法访问虚拟机中的DHCP服务器