This is what my code is intended to do: When called with the following array:
Code:
{ 1, 1, 1, 2, 2, 1, 2, 3, 3, 1, 1 }
, your function should modify the array to and store it.
Code:
#include <stdio.h>
#include <stdlib.h>
void compact (int[], int);
int main()
{
int arrSeries[11] = {1, 1, 1, 2, 2, 1, 2, 3, 3, 1, 1 };
int arrLength = 11;
compact(arrSeries, arrLength);
getchar();
return 0;
}
void compact(int arrSeries[], int arrLength)
{
int i, j= 0, counter=0, newArray[11];
newArray[0]=arrSeries[0];
for(i = 1; i != arrLength; i++)
{
if(newArray[j] != arrSeries[i-1]);
{
newArray[++j] = arrSeries[i];
}
}
while(counter !=6)
{
printf("%d ", newArray[counter]);
counter++;
}
}
However it is not working as intended. It works as if the IF statement doesn't even exist ! Where am I going wrong?
Thanks