+ 1
Why it's giving compilation error?
4 Réponses
+ 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.
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;
}
0
if you put base on blad() (błąd in polish mean error), main() doesn't see a blad().
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;
}