Standard input/output (stdio.h)
This header file defines the standard I/O predefined functions getchar(), putchar(), gets(), puts() and etc.
The predefined function getchar() is used to get a single character from keyboard and putchar() function is used to display it.
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
cout<<"\n Type a Character : ";
char ch = getchar();
cout << "\n The entered Character is: ";
putchar(ch);
return 0;
}
Type a Character : T
The entered Character is: T
Function gets() reads a string from standard input and stores it into the string pointed by the variable. Function puts() prints the string read by gets() function in a newline.
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
char str[50];
cout<<"Enter a string : ";
gets(str);
cout<<"You entered: "
puts(str);
return(0);
}
Enter a string : Computer Science
You entered: Computer Science
Related Topics
Privacy Policy, Terms and Conditions, DMCA Policy and Compliant
Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.