c - 删除 char 指针数组中的重复项

标签 c arrays pointers

我在 liste_tmp 中有一个指针数组,其值为“123”、“456”、“123”

声明:

char  *no_rlt_liste[5] , *liste_tmp[5]; int i, j, count =0;
for (i = 0 ; i < n; i++){
    for ( j= 0 ; j< count; j++){
            if (liste_tmp[i] == no_rlt_liste[j]){
                    break;
            }
            if (j == count){
                    no_rlt_liste[count]  = liste_tmp[i];
                    printf(" ENTER\n");
                    count++;
            }
    }
}
for (i = 0 ; i < count; i++)
    printf("Final result %s\n", no_rlt_liste[i]);

上面的代码没有产生结果。无法识别错误。 有帮助吗? 谢谢

最佳答案

你的 for由于条件j< count,循环永远不会运行, 你已经设置了 count =0 .

关于c - 删除 char 指针数组中的重复项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20280922/

相关文章:

javascript从具有相同对象和值的另一个数组的数组中删除

c - 将 volatile 分配给非 volatile 语义和 C 标准

C星号打印金字塔

c - 二元矩阵 vector 乘法的本质

c++ - 如何使用 Protocol Buffer ?

php - jquery中将json转换为数组

arrays - VBScript从txt文件中读取多个文件名并列出目录中不存在的文件名

c - 调用函数时出现段错误

c++ - 为什么某些 C/C++ 函数使用指针作为参数?

c++ - 堆数据困惑