介绍 C 语言中的字符操作
在 C 编程语言中,字符可以是 (A-Z(或)a-z)、数字 (0-9)、一个空格或一个特殊符号。
声明
以下是 C 编程中字符操作的声明 -
char a= ‘A’; using a character constant.
字符输入/输出函数
字符输入/输出函数的解释如下 -

示例 - char a;
scanf("%c", &a); printf ("%c", &a);
a = getchar ( ); putchar (a);
a = getch ( ); putch (a);示例
以下是使用 getchar() 进行行计数的 C 程序 -
#include <stdio.h>
/* count lines in input */
main(){
int count, num;
printf("enter multiple statements and Press cntrl+z:
");
num = 0;
while ((count = getchar()) != EOF)
if (count == '
')
++num;
printf("%d
", num);
}输出
以下为程序的输出 -
enter multiple statements and Press cntrl+z: Hi Hello Welcome To My World ^Z 4
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP