函数ReadDat()实现从数据文件in.dat巾读取一篇英文文章存入到字符串数组xx中,请编写函数ConvertCharA(),其函数的功能是:以行为单位把字符串中的所有小写字母改写成该字母的下一个字母。如果是字母z,则改写成字母a.大写字母和其他字符保

admin2013-12-10  26

问题 函数ReadDat()实现从数据文件in.dat巾读取一篇英文文章存入到字符串数组xx中,请编写函数ConvertCharA(),其函数的功能是:以行为单位把字符串中的所有小写字母改写成该字母的下一个字母。如果是字母z,则改写成字母a.大写字母和其他字符保持不变,把已处理的字符串仍按行重新存入字符串数组XX中。最后通过main()函数调用函数WriteDat()。把结果XX输出到文件out.dat中。
  例:原文:Adb.Bcdza
    abck.LLhj
    结果:Aec.Bdeab
    bcdl.LLik
    原始数据文件存放的格式是。每行的宽度均小于80个字符.含标点符号和空格。
【试题程序】
    #include
    #include
    char xxfi5031803 ;
    int maxline=0l    /*文章的总行数*/
    int ReadDat(void);
    void WriteDat(void);
    void ConvertCharA(void)
    {
    }
    void main()
    {
    if(ReadDat())f
    printf(“数据文件IN.DAT不能打开
\n\007”);
    return;
    }
    ConvertCharA();
    WriteDat();
    }
    int ReadDat(void)
    {
    FILE*fp;
    int i=0;
    char*P;
  if((fp=fopen(”in.dat”,”r”))==NULL)
    return 1;
while(fgets(xx~i3.80,fp)!=NULL){
    p=strchr(xx\n,);
    if(p)*p=0;
    i++1
  }
  maxline=i;
  fclose(fp);
  return 0;
}
void WriteDat(void)
{
FILE*fp;
int i;
fp=fopen(“out.dat”。“W”);
for(i=0Ii    printf(“%s\n”,xx);
    fprintf(fp,“%s\n”,xx);
  }
  fclose(fp);
}

选项

答案void ConvertCharA(void) { int i,j; /*定义变量*/ for(i=0;i=a,8L&xxEi]Ej]<=z) if(xx[i][j]==z)xx[i][j]=a; else xx[i][j]++; }

解析
转载请注明原文地址:https://jikaoti.com/ti/cv37FFFM
0

随机试题
最新回复(0)