Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #6623
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | "osmium" <r124c4u102@comcast.net> |
| Newsgroups | comp.lang.c++ |
| Subject | Re: cin and scanf which is best for simple input |
| Date | Sat, 11 Jun 2011 12:06:17 -0500 |
| Lines | 32 |
| Message-ID | <95hlk9Fpu4U1@mid.individual.net> (permalink) |
| References | <a0468c57-e5e2-4076-a27b-008a19b533d8@g28g2000yqa.googlegroups.com> |
| X-Trace | individual.net mFeHHR3gBVtbmmNP//Qkdw5wwzh6KDi7E8iOP8dFrlZEPjVeNT |
| Cancel-Lock | sha1:tShKrYN8V3asP6DXbUu6Ko1Wffg= |
| X-Priority | 3 |
| X-MSMail-Priority | Normal |
| X-Newsreader | Microsoft Outlook Express 6.00.2900.2180 |
| X-RFC2646 | Format=Flowed; Original |
| X-MimeOLE | Produced By Microsoft MimeOLE V6.00.2900.2180 |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.c++:6623 |
Show key headers only | View raw
"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