I posted the code below to demonstrate the meaning of successful input with
regards std::cin. But I am having problems with a few people.
These people insist that the term "input" with regards to the " cin>>object"
expression means the stage where some value is assigned to object.
It is blatantly obvious to me that it is just complete nonsense, so am I
missing something or , as I suspect, are these people just idiotic
thickheads who don't give a dam about what is correct?
Here is some code I used to demonstrate a situation where:
a) Input is successful
b) boolean test on (cin>>object) fails.
#include <iostream>
using namespace std;
int main()
{
int x;
cout << "Enter char from a to z:";
cin >> x;
while (x < 1 || x > 9)
{
cin >> x;
if (cin.fail())
{
cout<< "cin>>x failed!"<<endl;
cin.clear();
char c = cin.get();
cout<< "Your input was \'" << c << " \'. If this is true then input was
processed by this program." <<endl;
cout << "Try again:" << endl;
}
}
cout << "Program ending.... " << endl;
}
I think this code demonstrates successful input , however these people argue
with what appears to be clear evidence.
I get really annoyed with thick people sometimes and extremely annoyed with
thick people who are also ignorant fucks. So please tell me if I'm missing
something obvious.
TY
> I posted the code below to demonstrate the meaning of successful input with
> regards std::cin. But I am having problems with a few people.
Quite a few problems in software engineering are of social nature... :)
> These people insist that the term "input" with regards to the " cin>>object"
> expression means the stage where some value is assigned to object.
"input" is such a general term in software engineering that this
question becomes moot. It's hair-splitting, really. The important
question is more along the lines of: "Did my attempt to get a value from
the stream fail or is the object now safe to use?"
Leave the theory of Ideas ("what is true input?") to Platonism.
> Here is some code I used to demonstrate a situation where:
> a) Input is successful
> b) boolean test on (cin>>object) fails.
>
>
> #include <iostream>
> using namespace std;
>
> int main()
> {
> int x;
> cout << "Enter char from a to z:";
> cin >> x;
A better way to do this is to use std::getline and then check the first
character of the line, plus some error handling for illegal input.
> while (x < 1 || x > 9)
That's not really a to z...
> {
> cin >> x;
> if (cin.fail())
> {
> cout<< "cin>>x failed!"<<endl;
> cin.clear();
> char c = cin.get();
> cout<< "Your input was \'" << c << " \'. If this is true then input was
> processed by this program." <<endl;
> cout << "Try again:" << endl;
> }
> }
> cout << "Program ending.... " << endl;
> }
>
>
> I think this code demonstrates successful input , however these people argue
> with what appears to be clear evidence.
If someone enters the character 'A', then std::cin will go into a failed
state and nothing will be assigned to the variable. However, in order to
check the character the program obviously had to read it from the
stream. After all, how could you possibly check for a wrong value
without actually reading anything?
In this sense, input did happen, of course, because an external resource
(e.g. a keyboard) was queried by the system. I'm sure "these people"
would not argue that.
On the other hand, if you define "input" as the entire process up until
the object getting assigned a value, then no input happened because that
process is interrupted.
> I get really annoyed with thick people sometimes and extremely annoyed with
> thick people who are also ignorant fucks. So please tell me if I'm missing
> something obvious.
Just calm down! It's not worth getting annoyed about. You are both right :)
--
Christian Hackl
ha...@sbox.tugraz.at
Milano 2008/2009 -- L'Italia chiamň, sě!
You appear to be missing the ability to interact with others in a
civilized manner.
--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
"Keith Thompson" <ks...@mib.org> wrote in message
news:lnmxrhi...@nuthaus.mib.org...
> "news.virginmedia.com" <pchr...@yahoo.co.uk> writes:
> [snip]
>> I think this code demonstrates successful input , however these people
>> argue
>> with what appears to be clear evidence.
>> I get really annoyed with thick people sometimes and extremely annoyed
>> with
>> thick people who are also ignorant fucks. So please tell me if I'm
>> missing
>> something obvious.
>
> You appear to be missing the ability to interact with others in a
> civilized manner.
>
You appear to be the type of person that thinks people who swear are
uncivilized. But then appearances can be misleading.
> "news.virginmedia.com" <pchr...@yahoo.co.uk> writes:
> [snip]
>> I think this code demonstrates successful input , however these people argue
>> with what appears to be clear evidence.
>> I get really annoyed with thick people sometimes and extremely annoyed with
>> thick people who are also ignorant fucks. So please tell me if I'm missing
>> something obvious.
>
> You appear to be missing the ability to interact with others in a
> civilized manner.
I agree. Else-thread he plonked me just because my answer to his
question did "not make sense" to him. Software engineering is teamwork;
calling his colleagues "ignorant fucks" just because they don't agree on
some technical matters should have absolutely no place in this business
(or any other business, for that matter).
It's more about your attitude than about the words you use to express it.
"Christian Hackl" <ha...@sbox.tugraz.at> wrote in message
news:i6tpq9$hju$1...@news.eternal-september.org...
Who gives a toot if you agree or disagree. You are obviously a numbskull ,
get outta here if you have nothing constructive to say.
I plonked your post instantly because it was nothing more than idiotic
nonsense.
Plonk
"Keith Thompson" <ks...@mib.org> wrote in message
news:lnaanhi...@nuthaus.mib.org...
> "news.virginmedia.com" <pchr...@yahoo.co.uk> writes:
>> "Keith Thompson" <ks...@mib.org> wrote in message
>> news:lnmxrhi...@nuthaus.mib.org...
>>> "news.virginmedia.com" <pchr...@yahoo.co.uk> writes:
>>> [snip]
>>>> I think this code demonstrates successful input , however these
>>>> people argue
>>>> with what appears to be clear evidence.
>>>> I get really annoyed with thick people sometimes and extremely
>>>> annoyed with
>>>> thick people who are also ignorant fucks. So please tell me if I'm
>>>> missing
>>>> something obvious.
>>>
>>> You appear to be missing the ability to interact with others in a
>>> civilized manner.
>>>
>> You appear to be the type of person that thinks people who swear are
>> uncivilized. But then appearances can be misleading.
>
> It's more about your attitude than about the words you use to express it.
>
> --
So because my attitude is "uncivilized" you refuse to comment on the given
conversation and try to lead the conversation off on a negative tangent
about my having an uncivilised attitude.
Aye whatever. You 're probably as brain dead as those ignorant fuckpigs I
referred to earlier :)
Go read the porn spam or something dude.