Please look at my code:
adj = (int *)calloc(n * n, sizeof(int));
scanf("%d", &m);
for (i = 0; i < m; i++) {
scanf("%d %d %d", &x, &y, &w);
adjSetter(x - 1, y - 1, w);
adjSetter(y - 1, x - 1, w);
}
This part is in the main function and adjSetter is as below:
void adjSetter(int i, int j, int value) {
*(adj + (i * n + j) * sizeof(int)) = value;
}
Now the problem is when adjSetter function is called with i more than 2500 then I will get an Access Violation error. What's wrong with my code?
P.S.: n is 10000