
Untitled
By: a guest on
Apr 25th, 2012 | syntax:
C++ | size: 0.44 KB | hits: 19 | expires: Never
#include <iostream>
#include <limits>
using namespace std;
int main()
{
char buf[256];
// Read in a single word
cin >> buf;
cout << "Received: " << buf << endl;
// Clear error bits
cin.clear();
// Clear stdin
cin.ignore(std::numeric_limits<streamsize>::max(), '\n');
// Get a string up to a newline
cin.getline(buf, 256);
cout << "Received: " << buf << endl;
return 0;
}