I have made a function which takes a 1D array input and has to rearrange it. It is basically an array of cards and all the discarded cards are changed to OO. In this function, in the first for loop, I try to store the indexes of all the non-zero cards (which can be 26 in number max) and store them in an array called indexc. In the second for loop, I'm trying to rearrange the array using these indexes. However, when I cout indexc (just to check whether it works fine), the array doesn't fill up properly and its elements remain 0. I can't seem to figure out the problem. Can somebody help me with this, please?
int RearrangeComp(string rearrcomp[26])
{
int counterc = 0;
int indexc[26] = {};
int temp1 = 0;
int o = 0;
for (int m = 0; m < 26; ++m)
{
if(rearrcomp[m] != "00")
{
++counterc;
indexc[o] = {m};
++o;
}
}
for (int m = 0; m < 26; ++m)
{
}
for (int m = 0; m < 25; ++m)
{
temp1 = indexc[m];
if (indexc[m] != 0)
{
rearrcomp[m] = rearrcomp[temp1];
}
}