i have a problem with input array in function ; in this code i take an array parameter with the indexes from user and the function will print the table of 2D array with parameter reserve it ; here is the code :
#include <iostream>
#include <windows.h>
using namespace std ;
const char * table[3][2]={{"m1","m2"},{"n1","n2"},{"h1","h2"}} ;
void setTable(char *array,int n,int m) {
for(int i=0 ; i<n;i++){
for(int j=0 ; j<m;j++) {
cout<<array[i][j]<<"---" ; //print array
}
}
}
int main(){
setTable((char * )table,4,2) ; // send array with indexes to function
return 0;
}
but i have a error when i run it :
In function 'void setTable(char*, int, int)':
[Error] invalid types 'char[int]' for array subscript