You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.3 KiB

//删除单词
void DETL() {
int nu = 0,i=0;
system("cls");
VIEW();
if (fnum == 0) {
printf("\t\t****************************\n");
printf("\t\t* 请输入要删除的单词 *\n");
printf("\t\t****************************\n");
int m1=-1,qu=0,x=0;
char a[100];
scanf("%s", a);
struct w_word ap[100];
FILE *fp = fopen("wordd.txt", "r");
while (!feof(fp)) {
if (fread(&ap[i], sizeof(struct w_word), 1, fp) != NULL) {
i++;
}
}
fclose(fp);
if (i == 0) {
printf("\t\t* 无单词 *");
system("pause");
return;
}
for (int m = 0; m < i; m++) {
if (strcmp(ap[m].word_,a) == 0) {
m1 = m;
break;
}
}
if (m1 == -1) {
printf("\t\t* 无对应单词 *\n");
system("pause");
qu = 1;
}
else {
for (int s = m1; s < i; s++) {
ap[s] = ap[s + 1];
}
i--;
if ((fp = fopen("wordd.txt", "w")) == NULL) {
return;
}
for (int k = 0; k < i; k++) {
if (fwrite(&ap[k], sizeof(struct w_word), 1, fp) != 1) {
printf("* 删除失败 *\n");
system("pause");
x = 1;
}
}
fclose(fp);
//printf("* 删除成功 *");
}
if (x == 0&&qu==0) {
printf("\t* 删除成功 *\n");
printf("\t* 回车进入下一步 *\n");
system("pause");
}
return;
}
return;
}