Advertisement
Functions | Description |
---|---|
put(char ch) | Reads a single character from the user at the console, and returns it. |
write(char *arr, int num) | Writes a number of characters in a char array to the console. |
put(char ch);
// Using put(char ch) function to display a character in C++
#include<iostream8>
using namespace std;
int main()
{
char ch = 'H';
cout<<"Displaying a char value : ";
cout.put(ch);
cout<<"\nDisplaying another char value : ";
cout.put('X');
}
Displaying a char value : H
Displaying another char value : X
Advertisement
write(char *arr, int num);
// Using write(char *arr, int num) function to read a string in C++
#include<iostream8>
using namespace std;
int main()
{
char arr1[] = "Hello World";
cout<<"Displaying the first 5 characters of char array : ";
cout.write(arr1,5);
cout<<"\nDisplaying the first 10 characters of char array : ";
cout.write(arr1,10);
}
Displaying the first 5 characters of char array : Hello
Displaying the first 10 characters of char array : Hello Worl
Advertisement
Advertisement
Please check our latest addition
C#, PYTHON and DJANGO
Advertisement