请教一个C语言上机题目

来源:百度知道 编辑:UC知道 时间:2024/04/30 19:51:49
函数ReadDat()实现从文件ENG.IN中读取一篇英文文章存入到字符串数组XX中。请编制函数DelWord()分别按行删除空格、标点符号以及10个不区分大小写的英文单词(you,for,your,on,no,if,the,in,to,all),余下的单词仍按顺序重新存入数组XX中,最后调用函数WriteDat()把结果XX输出到文件PS.OUT中。
如原文为:You are a student.
则结果为:areastudent
原始数据文件存放的格式是:每行的宽度均小于80个字符,含标点符号和空格。
#include<stdio.h>
#include<string.h>
#include<conio.h>
#include<ctype.h>
char WORD[10][10]={"you","for","your","on","no","if","the","in","to","all"};
char XX[50][80];
int maxline=0;

在其中,ReadDat()函数为:
int ReadDat(void)
{FILE *fp;
int i=0;
char *p;
if((fp=fopen("ENG.IN","r")==NULL) return 1;
while(!fgets(xx[i],80,fp!=NULL)
{
p=strchr(xx[i],"\n");
if(P)
xx[i][p-xx[i]]=0;
i++;
}
maxline=i;
fclose(fp);
return 0;
}

我要问

1、在开始的时候定义的是一个二维数组XX[50][80],而在这个函数中怎么会只用XX[i]来引用
=======
引用xx[i]存放每行文本
p=strchr(xx[i],"\n")
xx[i][p-xx[i]]=0
=========
找到\n并以0替换,