#include<iostream>
#include<string>
usingnamespace std;
int main()
{
int row,col;
int y[3][3];
int x[3][3]=
{
{1,2,3},
{4,5,6},
{7,8,6}
};
for (int i = 0; i <= 2; i++)
{
for (int j = 0; j <= 2; j++)
y[i][j]=x[i][j];
row=i;
col=j;
cout<<y[i][j]<<endl;
}
cout<<x[i][j]<<endl; // i and j are unknown here
}
include<iostream>
#include<string>//1. not required
usingnamespace std;
int main()
{
int row,col;
int y[3][3];
int x[3][3]=
{
{1,2,3},
{4,5,6},
{7,8,6}
};
for (int i = 0; i <= 2; i++)//2. revise condition to i<3
{
for (int j = 0; j <= 2; j++)//3. ditto
y[i][j]=x[i][j];
row=i;//4. comment out
col=j;//5. ditto
cout<<y[i][j]<<endl;
}
for (int i = 0; i <= 2; i++)//6. revise condition to i<3 and add these 2 loops
{
for (int j = 0; j <= 2; j++)//7.ditto
cout<<x[i][j]<<endl; // i and j are unknown here-//8. now they are
}
Take a look at memcpy(p1,p2).....copies a block of memory (array) to another block.