Hi everybody.I can't initialize two-dimensional array. Eror in function
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
#include <iostream>
#include<iomanip>
using namespace std;
void init(int pmtx[][],int r,int c)
{
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
pmtx[i][j]=rand()%75;
}
}
}
int main()
{
int r=0;
int c=0;
cout<<"enter r "<<endl;
cin>>r;
cout<<"enter c "<<endl;
cin>>c;
init(pmtx,r,c);
return 0;
}
|
Last edited on
First off you may want to check out this link http://stackoverflow.com/questions/8767166/passing-a-2d-array-to-a-c-function
Questions regarding your question:
Is this for school?
I'm asking so I can know what tools you are allowed to use for this.
Do you know what the max value of r and c will ever be?
Have you learned pointers?
yes, it is for school.
right now i'm studing pointers.
No i don't know max value for r and c, let it be 5 and 5 (matrix)
Thomas, very thanks. Just right. I just can't understand why SRAND ??? Can you explain to me? Please.
Last edited on