two-dimensional dynamic array (realloc in c)
I am trying to load two double numbers from input to two-dimensional array dynamicaly realocated by every user input. #include <stdio.h> #include <stdlib.h> int main(int argc, char** argv) { int count; double number1, number2, **numbers; while (scanf("%lf,%lf", number1, number2) != EOF) { count++; numbers = (double**) realloc(numbers, count * 2 * sizeof (double)); if (numbers == NULL) { exit(1); } numbers[count][0] = number1; numbers[count][1] = number2; } return 0; } Program fails every time i try to save value into array (probably memory problem). It is compiled without problems. Can anyone