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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -