I have a system that read automatically the information stored on an access card of an employee in his company. These informations are stored in an array. When the card reader doesn't function, the employe have to enter his name and his Pin on the pinpad near the card reader to access the building, and the card reader will create automatically the informations to store in the array. The third first cells of the array are always filled with correct value and the rest of the cells with 0. My work is to access to this array and delete all the non-relevant zero after the third elements even though it exists a 0 before the third element, this have to be keep.
I have the following code:
#include <iostream>
#include <string>
using namespace std;
int main(){
int const Taille=5;
int Track2[Taille], i;
Track2[0]=1;
Track2[1]=0;
Track2[2]=3;
Track2[3]=0;
Track2[4]=0;
cout<<"voici le contenu du tableau: \n";
for(i=0;i<Taille;i++){
if(Track2[i]!=0){
cout<<"Track2["<<i<<"]= "<<Track2[i]<<"\n";
}
}
return 0;
}
When executing this I get the following result: voici le contenu du tableau: Track2[0]= 1 Track2[2]= 3 And I want to get this as result: voici le contenu du tableau: Track2[0]= 1 Track2[1]= 0 Track2[2]= 3 This means that, only the values that = 0, after the tird element of my array(here Track2[2]) have to be delete from my array. How can I do this please? Thanks