Expected primary-expression before "else"
That is the error I get in both "else" and "else if".
What is wrong in this code.( I searched all around and tried "everything" but found no solution.)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
int Answer1,Yes,No,yes,no;
cin >>Answer1;
if (Answer1=yes)(Answer1=Yes)
;
{
cout << "\nStuff here!\n";
}
elseif (Answer1=no)(Answer1=No)
;
{
cout << "\nMore stuff here!\n";
}
else
;
{
cout << "\nEven more stuff here!\n";
return 18; //Note:Line 18 is in my original code, line 1 here.
}
It`s just a part of and text based adventure. xD
A dialogue in it.
Edit: It supposed to work like "Do you want this?" if you say yes, you get it. If no you don`t. If neither you will get question like : "Are you sure?" and it begins in start.
int main ()
{
cout << "Stuff";
cout << "\n\nStuff\n\n";
int Name;
cin >> Name;
cout << "\nStuff\n";
cout << "<Press any key to do stuff.>\n\n";
system("pause>null");
cout << "Stuff.\n";
cout << "Stuff.\n";
int Answer1,Yes,No,yes,no;
cin >>Answer1;
if (Answer1==yes || Answer1==Yes)
{
cout << "\nStuff\n";
}
elseif (Answer1==no || Answer1==No)
{
cout << "\nStuff\n";
}
else
;
{
cout << "\nStuff\n";
return 18;
}
system("pause>nul");
}
Theres the whole "int main". Now the problem is that before that I put there that "if,if else,else"-thing, when I pressed any key it just went on. Now (after adding that code from int Answer1, etc. to return 18;} it just closes the program, with system("pause>null") or without.
Oh, sorry about not reading your previous comment with care. Anyways I think the problem is that the line "cin >>Answer1;" isn`t working properly, because I tried it without the "return", and program ignored line "cin >>Answer1;" and just shew me the line "else". I wasn`t able to do the Aswer1, program just skipped it.
Well, you never initialized your variables to anything.
So they have random bit patters in them right now, and I doubt those random bit patters match, so your if statement is always returning false causing you to always go to the else.
because Yes/No/yes/no are not ints. all your variables are of type int. You should put them as character arrays or strings if you want them to store info like that.