redbox <> wrote in message ...
> i want some code to get a int from user;
> code as show follow:
> #include <iostream>
> using namespace std;
> int main(){
> int c;
> cin>>c;
> while(cin.fail()){
> cout<<"Need a int,try again!"<<endl;
> cin.clear();
> cin.seekg(ios::end);
> cin>>c;
> }
> }
> but it work well in vc6 and ibm xlC,buf failed in g++;
Instead of 'seekg(end)', use 'cin.ignore(<somebigvalue>);'.
> who can tell me why ?
> thank you !
FAQ:
http://www.parashift.com/c++-faq-lite/
--
Bob R
POVrookie