数组去重,为什么运行出来是空的


#include
using namespace std;
void RemoveSame
(
    int b[],
    int nLen,
    int res[],
    int nLenRes
)
{
    nLen = 0;
    for (int i = 0; i < nLen; i++)
    {
        bool bExist = false;
        for (int j = 0; j < nLenRes; j++)
        {
            if (b[i] == res[j])
            {
                bExist = true;
                break;
            }
        }
        if (bExist)
            continue;
        res[nLenRes] = b[i];
        nLenRes++;
    }
}
int main()
{
    int b[8] = { 0,1,2,2,4,5,7,5};
    static int nLenRes;
    int res[99];
    RemoveSame(b, 8, res, nLenRes);
    for (int i = 0; i < nLenRes; i++)
        cout << res[i] << endl;
    return 0;
}

数组去重代码,为什么运行完什么都出现不了

main里的nLenRes一直是0啊,你定义成静态变量也没用啊。把子函数中最后一个参数改为引用类型,即int &nLenRes