Utility function for cin : cout manipulator « Console « C++






Utility function for cin

Utility function for cin
 
#include <iostream>
#include <cctype>
using namespace std;

istream &findalpha(istream &stream)
{
  char ch;

  do {
    stream.get(ch);
  } while(!isalpha(ch));
  return stream;
}

int main()
{
  char str[80];

  cin >> findalpha >> str;
  cout << str << '\n';

  return 0;
}



           
         
  








Related examples in the same category

1.Show time and date.Show time and date.
2.Turn on hex output with uppercase X.Turn on hex output with uppercase X.
3.Skip 10 characters.Skip 10 characters.
4.Set cout format: ios::showposSet cout format: ios::showpos
5.Set cout format: ios::showpoint | ios::uppercase | ios::scientificSet cout format: ios::showpoint | ios::uppercase | ios::scientific
6.Predefine format for coutPredefine format for cout
7.Define function to set coutDefine function to set cout
8.bell manipulator (using escape sequence \a)
9.ret manipulator (using escape sequence \r)
10.tab manipulator (using escape sequence \t)
11.endLine manipulator (using escape sequence \n and the flush member function)
12.Redirecting Standard Input And OutputRedirecting Standard Input And Output