Thanks! I was wondering about that, I tried it and now I'm having the opposite issue. It's ONLY going to the else statement, it seems there might be something wrong with the nested if statements? Also I'm getting these warnings when I compile:
||=== Build: Debug in auth (compiler: GNU GCC Compiler) ===|
||In function ‘int main()’:|
|17|warning: comparison between signed and unsigned integer expressions [-Wsign-compare]|
|17|warning: value computed is not used [-Wunused-value]|
|18|warning: left operand of comma operator has no effect [-Wunused-value]|
|18|warning: right operand of comma operator has no effect [-Wunused-value]|
|25|warning: left operand of comma operator has no effect [-Wunused-value]|
|25|warning: right operand of comma operator has no effect [-Wunused-value]|
|32|warning: left operand of comma operator has no effect [-Wunused-value]|
|39|warning: left operand of comma operator has no effect [-Wunused-value]|
|17|warning: ‘y’ may be used uninitialized in this function [-Wmaybe-uninitialized]|
||=== Build finished: 0 error(s), 9 warning(s) (0 minute(s), 0 second(s)) ===|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
#include <iostream>
#include <string>
void v()
{
std::cout << "Thank you for authorizing your product!";
}
int main()
{
std::string fn;
std::cout << "First Name: ";
std::cin >> fn;
int sn;
std::cout << "Serial #: ";
std::cin >> sn;
int y;
y==fn.length();
if (y==1, y==3, y==7)
{
if (sn==12540)
{
v();
}
}
else if (y==2, y==4, y==8)
{
if (sn==23651)
{
v();
}
}
else if (y==5, y==9)
{
if (sn==34762)
{
v();
}
}
else if (y==6, y==10)
{
if (sn==45873)
{
v();
}
}
else
{
std::cout << "Your information is not valid. Please check for typo's and try again.";
}
return 0;
}
|