Initializing multidimensional arrays : Multi Dimensional Array Initializing « Array « C Tutorial

Home
C Tutorial
1.Language
2.Data Type
3.String
4.printf scanf
5.Operator
6.Statement
7.Array
8.Function
9.Structure
10.Pointer
11.Memory
12.Preprocessor
13.File
14.Data Structure
15.Search Sort
16.Wide Character String
17.assert.h
18.ctype.h
19.math.h
20.setjmp.h
21.signal.h
22.stdio.h
23.stdlib.h
24.string.h
25.time.h
26.wctype.h
C Tutorial » Array » Multi Dimensional Array Initializing 
7.10.1.Initializing multidimensional arrays
#include <stdio.h>

void printArrayconst int a[][ ] )

int main()
{
   int array1][ { { 12}45} };
   int array2][ 1234};
   int array3][ { { 1}} };

   printf"Values in array1 by row are:\n" );
   printArrayarray1 );

   printf"Values in array2 by row are:\n" );
   printArrayarray2 );

   printf"Values in array3 by row are:\n" );
   printArrayarray3 );

   return 0;

}

void printArrayconst int a[][ ] )
{
   int i;
   int j;

   for i = 0; i <= 1; i++ ) {
      for j = 0; j <= 2; j++ ) {
         printf"%d ", a][ ] );
      

      printf"\n" );
   
}
Values in array1 by row are:
1 2 3
4 5 6
Values in array2 by row are:
1 2 3
4 5 0
Values in array3 by row are:
1 2 0
4 0 0
7.10.Multi Dimensional Array Initializing
7.10.1.Initializing multidimensional arrays
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.