- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Explain the Character operations in C language
Character can be (A-Z(or) a- z), digit (0-9), a white space, or a special symbol in C programming language.
Declaration
Following is the declaration for character operations in C programming −
char a= ‘A’; using a character constant.
Character input / output functions
The character input/output functions are explained below −
Example − char a;
scanf("%c", &a); printf ("%c", &a); a = getchar ( ); putchar (a); a = getch ( ); putch (a);
Example
Following is the C program for line counting using getchar() −
#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); }
Output
Following is the output of the program −
enter multiple statements and Press cntrl+z: Hi Hello Welcome To My World ^Z 4
Advertisements