// the istream cin. ignore() and
cin.get() member functions
#include <iostream>
using namespace std;
void main ()
{
char firstword, secondword;
cout<<"Enter your first and last names: ";
// read and store in firstword, get() function includes
white-space characters
firstword
= cin.get();
// extracts up to 30 elements and discards them, a space,
if encountered before 30,
// causes ignore() to return and
cin.ignore(30,' ');
// allowing all elements after a space to be read.
secondword
= cin.get();
cout<<"The initials letters are: "<<firstword<<secondword<<endl;
}
Output
0 Questions:
Post a Comment