如何修复错误“'strcmp”:形式参数1和实际参数1的不同类型”?
为什么会出现此错误: “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
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];