View Single Post
Old 04-14-2005, 12:12 PM   #4 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Quote:
...cant find anything on this site that has helped me so far...
This forum offers some neat solutions when it comes to streams. This is one of them:

Code:
#include <iostream>
#include <climits>

//-- using std::endl;
using std::cout;
using std::cin;
//-- void reset_istream() 
{
  if(cin.eof())
  {
    cin.clear(); 
  } else 
  {   
    cin.clear(); 
    cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');   
  } 
} 

//--------------------------------------- int main()
{
  char code[14];
  char reply;
  cout << "Please enter your code" << endl;
  cin.getline (code,14);
  cout << code << endl;
  cout << "Go again?" << endl;
  cin >> reply;
  if (reply =='y')
  {
  }
  reset_istream();
return 0;

}
__________________
Valmont is offline   Reply With Quote