Hello,
How to pass the char something[8][8] for example
to function
void ( char pass.....)???
You can declare the function in several ways. For example
void f(char s[][8], size_t n );
or
void f( char ( &s )[8][8] );
or
void f( char ( *s )[8][8] );
or void f( char **s, siize_t n. size_t m );
The last declaration requires to convert the argument to the type of the parameter.
Last edited on
print(
&board );
1 2 3 4 5 6 7 8 9 10 11 12 13
|
void print(char (*s)[8][8] ){
for(int i=0; i < 8 ; i++){
for(int k=0; k <8; k++){
cout <<( *s )[i][k];
}
cout << endl;
}
}
|
Last edited on
I forgot to mention one more method:)
template <size_t N = 8, size_t M = 8>
void f( char ( &s )[N][M] );
@vlad
Why the default template arguments? Can they not always be inferred?