I am trying to multiply two single arrays and printing out a 2D array...basically I'm making a multiplication table. I keep getting SEGMENTATION FAULT error. Any suggestions?

#include <stdio.h>
#define COLUMN_SIZE 12
#define ROW_SIZE 12
#define SIZE 12

int main (void)
{

int i, j, k;

int column[COLUMN_SIZE] = {1,2,3,4,5,6,7,8,9,10,11,12};
int row[ROW_SIZE] = {1,2,3,4,5,6,7,8,9,10,11,12};
int product[][SIZE] = {{},{}};

        for(int i=0; i<ROW_SIZE; i++){
                for(int j=0; j<COLUMN_SIZE; j++){
                        product[i][j] = row[i] * column[j];
                }
        }

        printf("%d\n", product[i][j]);

return 0;

}

Updated a little bit Now it prints out nothing. Probably infinite for loop somewhere.

#include <stdio.h>

int main (void)
{

int i, j;

int column[13] = {0,1,2,3,4,5,6,7,8,9,10,11,12};
int row[13] = {0,1,2,3,4,5,6,7,8,9,10,11,12};
int product[][13] = {{},{}};

        for(int i=0; i<sizeof(row); i++){
                for(int j=0; j<sizeof(column); j++){
                        product[i][j] = row[i] * column[j];
                }
        }

        printf("%d\n", product[i][j]);

return 0;

}

You need to define the size of the 2d array. The way you have it now it should the compiler will make it 2X12 whn you actually need it to be 12X12. I would change it to int prodouct[ROW_SIZE][COLUMN_SIZE];

Edited 4 Years Ago by NathanOliver

Comments
Thanks! Worked Perfectly

Comment Deleted

Edited 4 Years Ago by az-mi51: Comment Not Needed

This question has already been answered. Start a new discussion instead.