31st Dec 2017, 11:57 PM
Sebastian
Sebastian - avatar
4 Respostas
+ 3
You're comparing a string to an int here if((random==base[1] || random==base[2] || random==base[4] || random==base[6]) && releadOptRan >50) fix this and your code should run. It runs when this if statement is commented out.
1st Jan 2018, 12:56 AM
ChaoticDawg
ChaoticDawg - avatar
0
I'm not Pro In C++ As C....I dont Think There is String Type and the Array must be declared inside function...Here is a bit of The modified code That print Options #include <iostream> #include <conio.h> #include <ctime> #include <cstdlib> using namespace std; int blad() { char base[9][9]={"End", "New", "Year", "Star", "Drink", "Alcohol", "Snow", "Snowman","\aError!"}; int i; cout<<"All options: "; for(i=0; i<8; i++){ cout<<base[i]<<", "; } if(i>8){ cout<<base[9]<<"!"; } cout<<endl; return 0; } int main() { blad(); return 0; }
1st Jan 2018, 12:35 AM
Elie Douaihy
Elie Douaihy - avatar
0
if you put base on blad() (błąd in polish mean error), main() doesn't see a blad().
1st Jan 2018, 12:53 AM
Sebastian
Sebastian - avatar
0
Take It As Parameter in Function #include <iostream> #include <conio.h> #include <ctime> #include <cstdlib> using namespace std; int blad(char base[9][9]) { int i; cout<<"All options: "; for(i=0; i<8; i++){ cout<<base[i]<<", "; } if(i>8){ cout<<base[9]<<"!"; } cout<<endl; return 0; } int main() { char base[9][9]={"End", "New", "Year", "Star", "Drink", "Alcohol", "Snow", "Snowman","\aError!"}; blad(base); return 0; }
1st Jan 2018, 12:57 AM
Elie Douaihy
Elie Douaihy - avatar