The program is just for passing complete 2-d array to function.I am able to run the problem by hook or by crook but i didnt understood.I have written a program which i should have written threotically and which i have written to make it working(in comments) can anyone please explain me this issue??
#include<iostream>
#include<conio.h>
void print(bool *a);
using namespace std;
int main()
{
bool arr[3][3]={1,1,1,1,0,0,0,1,1};
print(arr[0]);//**This IS working but why we need subscript 0 here only print(arr) should work?..**
getch();
return 0;
}
void print(bool *a)
{
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
cout<<*(a+i*3+j)<<"|";//**cant we use cout<<a[i][j] here??In 1 d array it is working fine**
}
cout<<"--";
}
}