I created a function that takes an int array (pointer to a pointer), a maximum and a minimum value, and returns an array that consists only of numbers that lie in the interval min - max and the size of this "new" array.
But I just can not verify the correctness of the function, because I can not properly create this array of int 's and fill it with values: (
I'm just starting, please do not judge strictly.
Here is the function I created:
int ft_ultimate_range(int** range, int min, int max) { int size; int i; size = max - min; i = 0; if (size <= 0) return (0); *range = (int*)malloc(sizeof(int) * size); while (min < max) { *range[i] = min; min++; i++; } return (size); } And here is the array that I am trying to pass into it:
int* arra[10]; int indexX, indexY; int i; indexX = 0; indexY = 0; while (arra[indexX][indexY]) { while (arra[indexX][indexY]) { arra[indexX][indexY] = indexY; printf("%d\n", arra[indexX][indexY]); indexY++; } indexX++; indexY = 0; } i = ft_ultimate_range(arra, 1, 5); printf("%d\n", i); //Ничего не выводится On the line with the filling of the array gives an error:
ERROR: Use of uninitialised value of size 8.
while(arra[indexX][indexY])is what? In your example, there is no array filling - acade