Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何修复错误“'strcmp”:形式参数1和实际参数1的不同类型”?_C - Fatal编程技术网

如何修复错误“'strcmp”:形式参数1和实际参数1的不同类型”?

如何修复错误“'strcmp”:形式参数1和实际参数1的不同类型”?,c,C,为什么会出现此错误: “strcmp”:形式参数1和实际参数1的不同类型 ??这是我的密码: typedef struct materie { char *nume_mat[50]; int nota; struct materie *next; } materie; typedef struct student { char *nume[50]; char *prenume[50]; struct materie *prim; stru

为什么会出现此错误:

“strcmp”:形式参数1和实际参数1的不同类型

??这是我的密码:

typedef struct materie {
    char *nume_mat[50];
    int nota;
    struct materie *next;
} materie;

typedef struct student {
    char *nume[50];
    char *prenume[50];
    struct materie *prim;
    struct student *next;
} student; 

void adauga_student(student **lista, student *aux)
{
    student *q1, *q2;
    for (q1 = q2 = *lista;q1 != NULL && strcmp(q1->nume, aux->nume) < 0;q2 = q1, q1 = q1->next);
    if (q2 == q1)
    {
        aux->next = *lista;
        *lista = aux;
    }
    else
    {
        q2->next = aux;
        aux->next = q1;
    }
}
这:

。。。是一个由50个指针组成的数组。从语义上看,这似乎不是您想要的,而且它肯定不是strcmp作为参数所期望的

也许你想要的是

    char nume[50];
。。。50个字符的数组。这可以作为strcmp的参数,因为数组类型的表达式会衰减到指向第一个数组元素的指针。事实上,这是strcmp论证的标准形式之一


您可能希望对其他类似的声明进行相同的更改。

将for循环体硬塞进其条件中是一种糟糕的风格。读取它的功能并不容易。您需要创建一个字符串。strcmpq1->nume,aux->nume的参数是char*指针数组,它们应该是char数组。
    char nume[50];