PAGE2GO2 HOME | INTERNET NEWS

LeighExchange - Free Advertising Network Stock Research at Internet Speed Need Money Easy and Quick?

Re: cin char

 List
Subject: Re: cin char
Poster: Mike Wahler
Date: Fri, 23 Mar 2007 22:42:46 GMT
Related Postings: 1 2
"jraul" wrote in message news:1174597369.260904.128950@o5g2000hsb.googlegroups.com...
> Hi,
>
> If you cin >> x, where x if of type char, and you input a number 7,

What is really input is the character '7'. All stream operations are done as characters.


> it
> will read the char '7'.

Yes.


> However, char's are really integer types,

Type 'char' is one of the integer types, yes.


> so
> is it possible to set a flag so that you can input an integer that
> will fit in the range of a char (say 100)?

You can ask that a stream convert a sequence of input digit characters to an integer; use the proper overload:

int i; std::cin >> i;

You can determine whether this integer object's value is within type 'char's range:

if(i >= std::numeric_limits::min() && i <= std::numeric_limits::max()) ; /* in range of type 'char' */


> I don't think so, but just
> checking.

If you describe more specifically what you're trying to do, perhaps we can offer better advice.

-Mike

 

Page2Go2.com is not responsible for content of this message.