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;
}