In the loop below value is stored in fixarray only when element in array1 is not zero but its index gets incrementated even when element is zero.
for (i = 0; i < linect; i++)
{
if (array1[i] > 0.5)
{
fixarray1[i] = array1[i];
fixarray2[i] = array2[i];
}
}
In this loop index of fixarray should incrementated only when value in array1 is not zero .Something like this –
int j=0;
for(i = 0; i < linect; i++)
{
if(array1[i]>0.5)
{
fixarray1[j] = array1[i];
fixarray2[j] = array2[i];
j++;
}
}
This is will store value in fixarray only when element in array1 is not zero.
2
solved Array copies zeros? [closed]