#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(){
int n, i, check=0;
char first_name[20];
char current_name[20];
printf("Enter n, followed by n last names (each last name must be a single word):");
scanf("%d", &n);
scanf("%s", &first_name[20]);
for (i=1; i<n; i++){
scanf("%s", ¤t_name[20]);
if (strcmp(first_name[20], current_name[20])==0)
check = 1;
}
if (check == 1)
printf("First name in list is repeated.");
else
printf("First name in list is not repeated.");
system("pause");
return 0;
}
我使用开发的C++崩溃,我得到的错误是这样的:程序与字符串和数组
23:9 [注意]传递“的strcmp”的参数1,使指针从整数,未作铸[默认启用]
的程序运行,但它崩溃后,我在键入几个名字。
OMG感谢ü家伙!你所有的摇滚 – user3291455
它固定然后接受答案。 –