void ArrayCal();
int main(void)
{
ArrayCal();//calling fun.
return 0;
system("pause");
}
void ArrayCal()//this fun will scan elements into (Arr) the array of pointer
{
int a = 0, b = 0, c = 0, row = 0;
printf("Enter numbers of rows: ");
scanf("%d", &row);//scan rows
int* Arr = (int*)malloc(sizeof(int)*row);//to add more memory into the Arr
for (a = 0; a < row; a++)
{
printf("\nEnter array length for row %d: ", a + 1);
scanf("%d", &b);//scan length
*(Arr + a) = (int*)malloc(sizeof(int)*b);//to add more memory into the arrays
for (c = 0; c < b; c++)
{
printf("\nEnter value for array: ");
scanf("%d", Arr[row][b]);//scan value
}
}
sortPrint(Arr);//calling fun. to print the Arr
free(Arr);//to free the memory of the Arr.
for (a = 0; a < row; a++)
{
free(*(Arr + a));//to free the memory of the arrays
}
}
I'm trying to scan elements into array of pointer and I don't know why I have this bug.