Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!rochester!udel!princeton!phoenix!fine!levy From: levy@fine.Princeton.EDU (Silvio Levy) Newsgroups: comp.lang.c++ Subject: The >> operator Message-ID: <6622@phoenix.Princeton.EDU> Date: 23 Feb 89 22:32:14 GMT Sender: news@phoenix.Princeton.EDU Reply-To: levy@fine.UUCP (Silvio Levy) Organization: Princeton University, Princeton NJ Lines: 19 I've been using g++ for a couple of weeks, it's my first exposure to C++. I'm not very happy with the fact that when something like cin >> i; // i is an int fails (say because the next character is not a digit) the stream's _fail flag gets set, so no input from cin is possible until I reset that flag. This seems to be much more drastic that the corresponding situation in C, where a call to scanf() that returns 0 does not invalidate the input stream. Am I missing something? Is this the best possible design for >> ? Several of my C programs expect to be fed numbers and keywords, variously intermixed, and if the input is malformed an error message is given. It seems that in writing the same programs in C++ I'll have to add a call to clear() every time something unexpected is found in the input. A big pain, in my opinion. Silvio Levy