Guys I want your help on this please with filtering array

I want to enter a value each time to the originator[] and then delete every time the items in array[]which exist in the originator[]
example: originator[1]={0},array[counter1]={0,1,2} then filtered value should equal{1,2}
example1/originator[2]={0,2},array[counter1]={0,1,2,3} then filtered should equal{1,3} and so on..
any one can help plz??
int filtered[];
int i2=0;
int originator[6];
originator[i2]=value;//value it varies from time to time {0,1,2,4..}
cout<<"originator has"<<originator[i2]<<endl;
// cout<<"originator has"<<originator[i2-1]<<endl;
i2++;

for(int ii=0;ii<counter1;ii++){//counter1 gives how many item in the array[] defined global ..
for(int i1=0;i1<i2;i1++){
cout<<"orig has"<<originator[i1]<<endl;//
if(array[ii]!=originator[i1])
{
filtered=array[ii];//I think the error is here
...}//if
}//2nd for
}// 1st for
Last edited on
you can have a Counter variable to denote the index of filtered Variable...


int Counter3 ;
Counter3 =0;


for(int i1=0;i1<i2;i1++)
{
for(int ii=0;ii<counter1;ii++)
{


if(array[ii]!=originator[i1])
{
filtered[Counter3 ]=array[ii];
Counter3 ++;
for (int j = ii;j < (counter1-1); j++)
{
array[j] = array[j+1];
}
counter1 --;
ii = 0;


}//if
}//2nd for
}// 1st for

In this, outer loop for originator and inner loop for array. checking for unequality. the condition true delete the value from array and comparing first value of array.
Topic archived. No new replies allowed.