0

why this code in c++ doesn't compile?

i have a problem, clang tells me that i have to put brackets on the function's prototype: #include <iostream> #include <time.h> #include <cstdlib> using namespace std; void Giocatore( int n_pedine; int base; int altezza; char *A ){ int x=n_pedine; while(x>0){ A[srand()%base*altezza]='O'; x--; } } int main(){ int altezza, base, x; char A[altezza][base]; cin>>base>>altezza>>x; for(int i=0; i<altezza; i++){ for(int j=0; j<base; j++){ A[i][j]='*'; } } char *pA=&A[0][0]; for(int i=0; i<altezza; i++){ for(int j=0; j<base; j++){ cout<<A[i][j]; }cout<<endl; }//da eliminare a fine progetto Giocatore (x, base, altezza, pA); }

17th Dec 2019, 4:34 PM
riccardo
2 Antworten
+ 2
I didn't look in-depth, but the parameter list in the function definition should be comma-seperated, not semicolon-seperated. Furthermore you called srand() inside the function, where I think you meant rand(). Does that fix your issue?
17th Dec 2019, 4:43 PM
Shadow
Shadow - avatar
+ 1
And in main Declare array A after taking inputs to base,altezza..
17th Dec 2019, 5:45 PM
Jayakrishna 🇮🇳