新人摸不着头脑还请指点strcmp函数的实现
#include<stdio.h>#include<string.h>
#include<stdlib.h>
int main() {
int i=0,score=0;
FILE *p;
char ch;
char c[20]={'\0'};
char s[20]={'\0'};
p=fopen("D:\\C Myprogram\\word.txt","r");
ch=fgetc(p);
while(ch!=EOF) {
if(ch!='*') {
s[i]=ch;
printf("%c",ch);
i++;
}
if(ch=='*') {
printf("从键盘输入英文单词:\n");
gets(c);
printf("%d\n",strcmp(c,s));//明明输入一模一样,返回的值要么1要么-1
if(strcmp(c,s)==0)
score++;
}
i=0;
ch=fgetc(p);
}
printf("%d\n",score);
return 0;
}