0% found this document useful (0 votes)
8 views5 pages

Detailed IO Functions C CPP

The document provides an overview of various C/C++ I/O functions, including getch(), getche(), gets(), and puts(). Each function is explained with its purpose and accompanied by a simple example program. These functions are used for reading characters and strings from the keyboard, with specific functionalities for displaying input and handling user feedback.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views5 pages

Detailed IO Functions C CPP

The document provides an overview of various C/C++ I/O functions, including getch(), getche(), gets(), and puts(). Each function is explained with its purpose and accompanied by a simple example program. These functions are used for reading characters and strings from the keyboard, with specific functionalities for displaying input and handling user feedback.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

C/C++ I/O Functions

Detailed explanation with simple


programs
getch()
• Reads one character from the keyboard without showing it. Useful
for password input or pausing the screen.

• Example Program:
• #include <conio.h>
• #include <iostream>
• using namespace std;
• int main() {
• char ch;
• cout << "Press any key: ";
• ch = getch();
• cout << "\nYou pressed: " << ch;
• return 0;
• }
getche()
• Reads one character from the keyboard and displays it immediately.
Useful for taking single key input with feedback.

• Example Program:
• #include <conio.h>
• #include <iostream>
• using namespace std;
• int main() {
• char ch;
• cout << "Press any key: ";
• ch = getche();
• cout << "\nYou pressed: " << ch;
• return 0;
gets()
• Reads a full line of text including spaces.

• Example Program:
• #include <stdio.h>
• int main() {
• char name[50];
• printf("Enter your full name: ");
• gets(name);
• Cout<<“ you entered ”<< name<<endl;
• }
puts()
• Displays a string and automatically adds a newline.
Only used for strings.

• Example Program:
• #include <stdio.h>
• int main() {
• char name[] = "Hina";
• puts(name);
• return 0;
• }

You might also like