【问题标题】:Casting error when using strcmp function使用 strcmp 函数时出现转换错误
【发布时间】:2013-09-20 01:07:30
【问题描述】:

我正在尝试使用 strcmp 比较 2 个数组,但在编译时错误显示“传递‘strcmp’的参数(1 和 2)使指针从整数不进行强制转换”。有谁知道我犯的错误在哪里?

char    file1[MAX_MAC_ADD][BIG_NUM];
char    save_MAC[MAX_MAC_ADD][BIG_NUM];
int unique_MAC = 0;


    char temp1[16];
    char temp2[16];
    for(int i= 0; i <17; i++)
    {
        temp1[i] = file1[2][i];
    }
    for(int i = 0; i < unique_MAC+1; i++)
    {
        for(int j = 0; j <17; j++)
        {
            temp2[j] = save_MAC[i][j];
        }
    }
    //if not the same
    if(strcmp(temp1, temp2 != 0))
    {
        //copy address into save_MAC
        strcpy(save_MAC[unique_MAC], temp1);
        unique_MAC++;
    }

【问题讨论】:

    标签: c arrays strcmp


    【解决方案1】:

    一个错位的“)”:

    if(strcmp(temp1, temp2) != 0)
    

    【讨论】:

      猜你喜欢
      • 2021-03-17
      • 1970-01-01
      • 2013-06-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-14
      • 2012-09-03
      • 1970-01-01
      相关资源
      最近更新 更多