c语言getchar函数_C语言中带有示例的getchar()函数

c语言getchar函数

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

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

getchar()函数在<stdio.h>头文件中定义。

Prototype:

原型:

    int getchar(void);

Parameters: FILE *filename(for file handling), otherwise it will be void.

参数: FILE * filename(用于文件处理) ,否则为空。

Return type: int

返回类型: int

Use of function:

使用功能:

In the file handling, through the getchar() function we take the character from the input stream stdin. The prototype of the function getchar() is int getchar(void);

在文件处理中,通过getchar()函数,我们从输入流stdin中获取字符。 函数getchar()原型是int getchar(void);。

The character which is read is an unsigned char which is converted to an integer value. In the case of file handling, it returns EOF when end-of-file is encountered. If there is an error then it also returns EOF.

读取的字符是无符号字符 ,该字符将转换为整数值。 在文件处理的情况下,遇到文件结尾时它将返回EOF 。 如果有错误,则它还会返回EOF 。

C语言中的getchar()示例 (getchar() example in C)

#include <stdio.h>
#include <stdlib.h>
int main(){
//Initialize the character array
char str[100];
int i=0,j=0;
printf("Enter the string into the file\n");
//takes all the characters until enter is pressed
while((str[i]=getchar())!='\n'){
//increment the index of the character array
i++;
}
//after taking all the character add null pointer 
//at the end of the string
str[i]='\0';
printf("\nThe file content is - ");
//loop is break when null pointer is encountered
while(str[j]!='\0'){
//print the characters
putchar(str[j]);
j++;
}
return 0;
}

Output

输出量

getchar() example in C language

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

c语言getchar函数

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/542140.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

python及pycharm

1.python简介&#xff1a; Python是一种计算机程序设计语言。是一种动态的、面向对象的脚本语言&#xff0c;最初被设计用于编写自动化脚本(shell)&#xff0c;随着版本的不断更新和语言新功能的添加&#xff0c;越来越多被用于独立的、大型项目的开发。 python最重要的功能&am…

anaconda如何更改环境配置_手把手教新手安装Anaconda配置开发环境

Anaconda是针对Python的集成环境&#xff0c;它已经成为全球数千万数据科学从业人员必备的开发工具&#xff0c;帮助人们有效地解决数据科学和机器学习相关地问题。如果你想从事数据科学和机器学习的工作&#xff0c;可以从本文开始&#xff0c;了解一下如何安装Anaconda。1. 初…

详解摘要认证

1. 什么是摘要认证摘要认证与基础认证的工作原理很相似&#xff0c;用户先发出一个没有认证证书的请求&#xff0c;Web服务器回复一个带有WWW-Authenticate头的响应&#xff0c;指明访问所请求的资源需要证书。但是和基础认证发送以Base 64编码的用户名和密码不同&#xff0c;在…

Python的基础知识

1.注释&#xff1a; #单行注释ctrl / 批量注释&#xff0c;选中需要注释的所有行ctrl / 批量取消注释&#xff0c;选中已经被注释的所有行 块注释&#xff1a;上下各三个双引号的部分全部被注释 “”“ hello haha ”“”2.变量&#xff1a; 变量命名的规则&#xff1a; …

树莓派该文件名_树莓派:文本编辑器与文件

GNU nano是Unix系统下一款常用的文本编辑器&#xff0c;以简单易用著称。与之相比&#xff0c;功能更强大的Vi和Emacs编辑器&#xff0c;学习曲线比nano陡峭很多。由于nano对于一般的文本编辑来说已经足够&#xff0c;所以我想简单介绍一下&#xff0c;以便于更好入门。基本使用…

Java SimpleTimeZone setStartYear()方法与示例

SimpleTimeZone类setStartYear()方法 (SimpleTimeZone Class setStartYear() method) setStartYear() method is available in java.util package. setStartYear()方法在java.util包中可用。 setStartYear() method is used to set the DST (Daylight Savings Time) starting y…

报表在IBM AIX系统下resin部署

&#xfeff;&#xfeff;报表是用java开发的&#xff0c;具有良好的跨平台性。不仅可以应用在windows、linux、操作系统&#xff0c;还可以应用在AIX等等的unix操作系统。在各种操作系统上部署过程有一些差别。下面说一下在AIX操作系统的部署的步骤。 1. 首先&#xff0c;下载…

python——if语句、逻辑运算符号

1.if条件判断语句&#xff1a; if 要判断的条件(True):条件成立的时候&#xff0c;要做的事情 elif 要判断的条件(True):.... elif 要判断的条件(True):.... else:条件不成立的时候要做的事情示例&#xff1a; 判断学生分数等级&#xff1a; 100——90&#xff08;包括90&…

sox处理mp3_使用SoX将mp3文件拆分为TIME秒

I need to split mp3 file into slices TIME sec each. Ive tried mp3splt, but it doesnt work for me if output is less than 1 minute.Is it possible do do with:sox file_in.mp3 file_out.mp3 trim START LENGTHWhen I dont know mp3 file LENGTH解决方案You can run SoX…

Java ObjectOutputStream writeInt()方法及示例

ObjectOutputStream类writeInt()方法 (ObjectOutputStream Class writeInt() method) writeInt() method is available in java.io package. writeInt()方法在java.io包中可用。 writeInt() method is used to write the given 4 bytes of an integer value. writeInt()方法用于…

移动端适配方案(上)

转载自:https://github.com/riskers/blog/issues/17 要搞懂移动端的适配问题&#xff0c;就要先搞明白像素和视口。 像素 在移动端给一个元素设置 width:200px 时发生了什么&#xff1f;这里的px到底是多长呢&#xff1f;像素是网页布局的基础&#xff0c;但是我们一直在用直觉…

python——rang函数、for、braek循环

rang函数&#xff1a; start: 计数从 start 开始。默认是从 0 开始。例如range&#xff08;5&#xff09;等价于range&#xff08;0&#xff0c; 5&#xff09;; stop: 计数到 stop 结束&#xff0c;但不包括 stop。例如&#xff1a;range&#xff08;0&#xff0c; 5&#xf…

Java文件类boolean isHidden()方法(带示例)

文件类boolean isHidden() (File Class boolean isHidden()) This method is available in package java.io.File.isHidden(). 软件包java.io.File.isHidden()中提供了此方法。 This method is used to check whether the file is hidden or not. 此方法用于检查文件是否隐藏。…

js导出的xlsx无法打开_js-xlsx 导出表格至excel

引入js文件下载地址&#xff1a;链接: https://pan.baidu.com/s/1gdOl1HnTrM5mZgPgd5qeDQ 提取码: c8js导入4个js文件js/xlsx.extendscript.js,js/xlsx.full.min.js,js/export.js,js/jszip.js,js/xlsx-style/xlsx.full.min.js其中 js/xlsx-style/xlsx.full.min.js 是表格样式的…

oracle sql 语句如何插入全年日期?

为什么80%的码农都做不了架构师&#xff1f;>>> oracle sql 语句如何插入全年日期&#xff1f; create table BSYEAR (d date); insert into BSYEAR select to_date(20030101,yyyymmdd)rownum-1 from all_objects where rownum < to_char(to_date(20031231,…

getparent_Java文件类字符串getParent()方法(带示例)

getparent文件类字符串getParent() (File Class String getParent()) This method is available in package java.io.File.getParent(). 软件包java.io.File.getParent()中提供了此方法。 This method is used to return the parent of the given file object(i.e In case of f…

python—while循环、字符串

1. while循环&#xff1a; while 条件满足&#xff1a;满足条件执行的语句 else:不满足条件执行的语句while 死循环 只要满足 while的条件永远为真&#xff0c;就会进入无限循环 while True:print(一直循环)while嵌套 \t &#xff1a;在控制台输出一个制表符&#xff0c;协助…

java基础——java基本运算

java基本运算 转载于:https://www.cnblogs.com/zhouj/p/6132535.html

【Java】MybatisPlus

MybatisPlus MybatisPlus是在mybatis基础上的一个增强型工具。它对mybatis的一些操作进行了简化&#xff0c;能够提高开发的效率。 springboot整合了mybatis之后&#xff0c;其实已经非常方便了&#xff0c;只需要导入mybatis的包后&#xff0c;在配置文件中编写数据源信息&a…

机器人总动员拟人后_WALL·E 机器人总动员——又是一部让名字耽误的高分电影...

WALLE 机器人总动员(2008)导演&#xff1a; 安德鲁斯坦顿简单&#xff0c;却惹人落泪的动画电影。名字叫做机器人总动员&#xff0c;说实话&#xff0c;这部电影高高的挂在豆瓣的排行榜上&#xff0c;但却因为名字被我总是忽视掉&#xff0c;我好像就是这么肤浅的人呀~电影是由…