Hi,
I wrote this simple program to time a program. I wanted to time the writes to a matrix. but for some reason the program gives me a segmentation fault. can anyone please tell me why.
Code:
/* Program to time matrix writes */
#include <stdio.h>
#include <time.h>
#define SIZE 100
void MatrixWrite(int matrix[SIZE][SIZE]){
int i = 0;
int j = 0;
for(i = 0; i < SIZE; i++){
for(j = 0; j < SIZE; j++){
matrix[i][j] = i+j; /* initialize matrix[i][j] to i+j */
}
}
}
int main()
{
clock_t start = clock();
int matrix[SIZE][SIZE] = {}; /* initialize a matrix to NULL*/
MatrixWrite(matrix[SIZE][SIZE]);
printf("Time elapsed: %f\n", ((double)clock() - start) / CLOCKS_PER_SEC);
return 0;
}