# Thread: remove strings from array

1. ## remove strings from array

Hi all!
I'm having a trouble to exclude (substitute with the next string) repeated strings from an array:

Code:
```char hst[30][30];  /* stored strings */
int qt_hst; /* amount of strings at hst */
int rptds[10]; /* store which lines numbers are repeated strings */
int a, b;
...

a = b = 0;
while (b = rptds[a])
{
for (b; b<=qt_hst; b++)
strcpy(hst[b-a], hst[b-a+1]);
a++; qt_hst--;
}```
But this code don't work properly. Mainly if the rptds[x] > rptds[x+1]

2. > while (b = rptds[a])

Should probably be: while (b == rptds [a])

> b<=qt_hst

You realise that arrays have first index being 0, so perhaps it should be b < qt_st?

> strcpy(hst[b-a], hst[b-a+1]);

You could do a little debugging by printing the values of b-a and b-a+1 and then check if those values are not above 30, which is the maximum number of stored strings.

3. >> while (b = rptds[a])
> Should probably be: while (b == rptds [a])
no. is really b = rptds[a]

> b<=qt_hst
You realise that arrays have first index being 0, so perhaps it should be b < qt_st?
the counter also starts on 0.

> strcpy(hst[b-a], hst[b-a+1]);

>You could do a little debugging by printing the values of b-a and b-a+1 and then check if those values are not above 30, which is the maximum number of stored strings.

I already did. I couldn't find the bug.
Please, let me know if someone have a solution for this code.