I have an array points
which is a 2d array. The function fillPoints
is supposed to fill the array manually with values. I'm getting the Exception EXC_BAD_ACCESS (code=1, address=0x0)
on CLion IDE. I suppose there's something wrong with how I handle pointers. This is the code:
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <ctype.h>
#define POINTS_LEN 4
#define A_LEN 200
void fillPoints(int ** pointsArr, int arr_len);
int main() {
int A[A_LEN];
int points[2][POINTS_LEN];
fillPoints(points, A_LEN);
return 0;
}
void fillPoints(int ** pointsArr, int arr_len) {
pointsArr[0][0] = arr_len/4;
pointsArr[0][1] = arr_len/2;
pointsArr[0][2] = (3*arr_len)/4;
pointsArr[0][3] = arr_len;
pointsArr[1][0] = 0;
pointsArr[1][1] = 1;
pointsArr[1][2] = 2;
pointsArr[1][3] = 3;
}