Try to search your question here, if you can't find : Ask Any Question Now ?

"Deleting" from array in C

HomeCategory: stackoverflow"Deleting" from array in C
sourav asked 2 weeks ago

So I have a string array in a struct where i stored car’s number-plates and i want to print those number-plates (a number-plate can occurs several times) which occour more than 1x (at least 2 times) to a file, but only once!

        typedef struct plates{
        char plate[10];
        char gate[25];}PL; //does not matter in this case


        PL r[50];
        int length=50;
        char nullStr[5]={''};
        for(int i=0; i<length; i++)
        {
            for(int j=i+1; j<length; j++)
            {
                if(strcmp(r[i].plate,r[j].plate)==0){
                    strcpy(r[j].plate, nullStr);
                    fprintf(f_out, "%sn", r[i].plate);

                }
            }

        }

input: ASD123, QWE123, ASD123, KKR332, ASD123, QWE123,

output should be: ASD123, QWE123

but i get: ASD123, ASD123, QWE123

1 Answers
Best Answer
Jyoti answered 2 weeks ago
Your Answer

2 + 12 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com