#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
它固定然後接受答案。 –