I want my program to read several lines of votes, which could be A,P,Y or N, until # is reached. Each line corresponds to one final result.
What I have so far is I enter one line of votes and I always get "need quorum" as an output regardless of the input, and program ends.
Can anyone help me with the code, I don't know what I'm doing wrong. Thank you
Hi Mazaret. You're doing pretty good. Not bad that you wrote this on your own.
However, there are a couple of pretty big errors I can see in your code. I'll start with why your code is always displaying need quorum.
On line 19 you write if (v = '#') break;
But what you mean to type is if (v == '#') break;
"==" and "=" are two fundamentally different commands to the computer. "==" is used to compare values. "=" is used to set values.
Second, on lines 15 and 18, you rely on ins.get(v);
I wouldn't do that, I would either do this,
1 2 3
ins.ignore(256, '\n');
ins.clear();
ins.get(v);
or this ins >> v;
Both are logically equivalent.
See if you can figure out the rest. Keep in mind that '=' and '==' are totally different.
Fixed the issue thank you.
However that's still not what I want. I'm trying to make it so that for each line it reads, it prints an output until "#" is reached to indicate end of program. Right now it is reading several lines until "#" is entered, and outputs just one output. ( for all the lines that is )
Let me know if you have any idea on how to fix it and thank you :) I'm kind of stuck