c++ - static 2d array initialisation -
how initialize static 2d array
i trying initialize static 2d array statment 'static int b[n][m]={}' , showing error, while on giving const parameters, it's working 'static int b[2][10]={}'
#include<iostream> using namespace std; void a(int c, int n, int m){ static int b[n][m]={}; // static int b[2][10]={}; , here working fine for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ b[i][j] = i+j; cout<<b[i][j]<<" "; } } } int main(){ int c; cin>>c; a(c,2,10); cout<<endl; return 0; }
you initialized array 0.
if whant initialize else try this
static int ar[2][3]={{1,2,3},{4,5,6}};
Comments
Post a Comment