Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #6623
| From | "osmium" <r124c4u102@comcast.net> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: cin and scanf which is best for simple input |
| Date | 2011-06-11 12:06 -0500 |
| Message-ID | <95hlk9Fpu4U1@mid.individual.net> (permalink) |
| References | <a0468c57-e5e2-4076-a27b-008a19b533d8@g28g2000yqa.googlegroups.com> |
"papoupapa" wrote::
<snippage>
> Can someone tell from the code below why scanf solves the issue of a
> number out of
>
> the range and cin seems to read twice a great number such as
> 100000000000 or go into a wild loop if a character or some text is
> entered.
>
> #include "std_lib_facilities.h"
>
> int main()
> {
> int val1 = 0 ;
> int val2 = 0 ;
> int nb_try ;
> bool ok = 0 ;
>
> cout << "\nThis code reads 2 numbers and takes these 2 numbers into
> simple
I suggest you simplify things. You seem to think cin does something wrong.
Write a *current* conforming C++ program with cin and only cin which
exhibits the problem. Don't complicate things with a second program using
scanf. In general, the use of scanf is discouraged. WRT conforming:
o your include file is not standard.
o your program will not compile. A simple cout will no longer be accepted.
My wild guess is that your use of "solve" is misguided.
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
cin and scanf which is best for simple input papoupapa <papoupapoug@gmail.com> - 2011-06-11 03:53 -0700
Re: cin and scanf which is best for simple input "osmium" <r124c4u102@comcast.net> - 2011-06-11 12:06 -0500
Re: cin and scanf which is best for simple input "Sprechen Sie C++" <spamabuse@hotmail.com> - 2011-06-11 10:50 -0700
Re: cin and scanf which is best for simple input Kai-Uwe Bux <jkherciueh@gmx.net> - 2011-06-11 20:29 +0200
Re: cin and scanf which is best for simple input papoupapa <papoupapoug@gmail.com> - 2011-06-12 16:25 -0700
csiph-web