2012-02-26 57 views
0

我想顯示一個2維數組。顯示一個二維數組

int arr[numRows][numCols] = {{0,1,2,3,4,5,6},{7,8,9,10,11,12,13},{14,15,16,17,18,19,20}}; 

void display(int p[][numCols]) 
{ 
     //printf("\n"); 
     for (int i = 0; i< numRows;i++) 
     { 
      for (int j = 0;i< numCols;j++) 
      { 
      printf("%i\t",p[i][j]); 
      } 
      printf("\n"); 
     } 
} 

但我有一些錯誤信息顯示up.Not sure如何解決這個問題。

enter image description here

屏幕輸出:enter image description here

整個代碼可以在這裏找到:

https://codereview.stackexchange.com/questions/9419/programming-of-3-x-7-trick

+0

你是怎麼稱呼它的? – 2012-02-26 07:16:24

+0

編輯了這個問題.... – lakesh 2012-02-26 07:20:31

回答

4

您有簡單的印刷錯誤 - 而不是:

for (int j = 0;i< numCols;j++) 

使用

for (int j = 0;j< numCols;j++)