0% found this document useful (0 votes)
12 views15 pages

Unit 2 Part B

This document outlines the curriculum for the Bachelor of Technology in Computer Science Engineering, focusing on the 'Introduction to Programming with C' course. It covers important character I/O functions such as getc(), getchar(), getch(), getche(), putchar(), and putc(), along with file operations in C programming. Additionally, it provides references for further reading on C programming.

Uploaded by

pranav verma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views15 pages

Unit 2 Part B

This document outlines the curriculum for the Bachelor of Technology in Computer Science Engineering, focusing on the 'Introduction to Programming with C' course. It covers important character I/O functions such as getc(), getchar(), getch(), getche(), putchar(), and putc(), along with file operations in C programming. Additionally, it provides references for further reading on C programming.

Uploaded by

pranav verma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Course Name: Bachelor of Technology(B.

Tech-CSE)
Course Code: 19002200
Subject: Introduction to Programming with C (Unit-2-Part-B)

Faculty Name:
Dr. Saba Hilal

Professor (CSE)
School of
Engineering &
Technology

Programme Name Semester- B.Tech-I-Sem Subject- Introduction To Programming with C


Topics
• getc()
• getchar()
• getch()
• getche()
• putchar()
• putc()
• File Operations

Programme Name Semester- B.Tech-I-Sem Subject- Introduction To Programming with C


Important Functions for Character I/O
What is getc()?
The getc() reads one character from any input and then returns the
corresponding value of the integer on success (typically, the ASCII
value of the read character). On failure, it then returns the EOF.

Here, Syntax:
int getc(FILE *stream);

Programme Name Semester- B.Tech-I-Sem Subject- Introduction To Programming with C


Important Functions for Character I/O
What is getchar()?
The primary difference between the getchar() and getc() is that the
getc() is capable of reading from any input scheme, while the
getchar() is capable of reading from the standard input. Hence,
getchar() becomes equivalent to the getc(stdin).

Here, Syntax:

int getchar(void);

Programme Name Semester- B.Tech-I-Sem Subject- Introduction To Programming with C


Important Functions for Character I/O
What is getch()?
The getch() is a type of non-standard function which is present in
the file of conio.h. Mostly, the MS-DOS compilers utilize it, like the
Turbo C. It does not fall into a part of the standard library of C or ISO
C. It is capable of reading a single character from any given
keyboard. Since it doesn’t make use of any buffer, the entered
character returns immediately without having to wait for the enter
key.
Here, Syntax:
int getch();
Programme Name Semester- B.Tech-I-Sem Subject- Introduction To Programming with C
Important Functions for Character I/O
What is getche()?
Just like gentch(), the getche() is also a non-standard type of
function that is present in the conio.h file. It is capable of reading
one character from any given keyboard and displaying it
immediately on the output screen without the character having to
wait for the enter key.

Here, Syntax:

int getche(void);
Programme Name Semester- B.Tech-I-Sem Subject- Introduction To Programming with C
Important Functions for Character I/O

Programme Name Semester- B.Tech-I-Sem Subject- Introduction To Programming with C


Important Functions for Character I/O
What is putchar()?
putchar() function is used to write a character on standard
output/screen. In a C program, we can use putchar function as
below.
Syntax:
putchar(char);

where, char is a character variable/value.

Declaration: int putchar(int char)

Programme Name Semester- B.Tech-I-Sem Subject- Introduction To Programming with C


Important Functions for Character I/O
What is putc()?
putc( ) function is used for writing a character into a file.

The syntax for putc() function is as follows −


putc (char ch, FILE *fp);

For example,

FILE *fp;
char ch;
putc(ch, fp);

Programme Name Semester- B.Tech-I-Sem Subject- Introduction To Programming with C


Important Functions for Character I/O

Programme Name Semester- B.Tech-I-Sem Subject- Introduction To Programming with C


File Operations
The operations on files in C programming language are as follows −

• Naming the file


• Opening the file
• Reading from the file
• Writing into the file
• Closing the file

Programme Name Semester- B.Tech-I-Sem Subject- Introduction To Programming with C


File Operations
• Naming the file
• Opening the file
• Reading from the
file
• Writing into the
file
• Closing the file

Programme Name Semester- B.Tech-I-Sem Subject- Introduction To Programming with C


getchar() and putchar() examples

Programme Name Semester- B.Tech-I-Sem Subject- Introduction To Programming with C


getc() and putc() examples

Programme Name Semester- B.Tech-I-Sem Subject- Introduction To Programming with C


Reference Books and Links
1. Ashok N. Kamthane, “Computer Basics and C Programming”, Pearson Education.
2. E. BalaGuruswamy, “Programming in ANSI C”, 2008.
3. V Rajaraman, “Computer Basics and C Programming”, PHI.
4. Herbert Schildt, “C The Complete Reference” Fourth Edition, 2000.
5. YashwantKanetkar, “Let us C” eighth edition, 2002.
6. Kernighan and d. Ritchie, “The ANSI C Programming Language”, 2000.
7. StephennPrata, “C Primer Plus” Fourth Edition, 2001.
8. Schaum’s Outline Series, “Programming with C”, 2nd Edition, 1996.
9. https://www.tutorialspoint.com/explain-putc-and-getc-functions-of-files-in-c-language
10. https://byjus.com/gate/difference-between-getc-getchar-getch-and-getche/.

Programme Name Semester- B.Tech-I-Sem Subject- Introduction To Programming with C

You might also like