-1

I want to initialize multidimensional array in C. I use usually the code below.

#include <stdio.h>
int main()
{
    int a[10][10] = {{0}, {0}};
    return 0;
}

Is my code right, and is there any specific, quick code for me?

J. H. Kim
  • 7
  • 3
  • Did you test it and you were not happy? Or this is a test to see which user has the reputation-fever to answer? :) – gsamaras Aug 19 '16 at 23:48

1 Answers1

0

Initialization:

int a[3][4] = {  
    {0, 1, 2, 3} ,   /*  initializers for row indexed by 0 */
    {4, 5, 6, 7} ,   /*  initializers for row indexed by 1 */
    {8, 9, 10, 11}   /*  initializers for row indexed by 2 */
 };

And with for loops:

int i,j,a[10][10];
for(i=0;i<10;i++)
    for(j=0;j<10;j++)
        a[i][j] = 1;
Dr.Haimovitz
  • 1,568
  • 12
  • 16