请教 一段程序出错的原因
我的源代码是怎么写的,可不管怎么更改还是不能被编译,请指教,万分感谢;
- C/C++ code
#include<stdio.h>#include<conio.h>#include<stdlib.h>#include<string.h>#include<ctype.h>system("cls")unsigned char xx[50][80];//运行到这里就出现下面两个错误;//error C2448: '<Unknown>' : function-style initializer appears to be a function definition;//fatal error C1004: unexpected end of file found;int maxline=0;//文章的总行数;int readdat();//声明一个函数;void writedat();void encryptchar()//对数组中的所有字符进行替代函数;{ int i,j,m; for(i=0;i<maxline;i++) for(j=0;xx[i][j];j++) { m=xx[i][j]*11%256; if(xx[i][j]%2==0||m<=32); else xx[i][j]=xx[i][j]*11%256; }}void main()//主函数;{ clrscr();//清屏; if(readdat())//判断能否完成打开工作; { printf("数据文件ENG.IN不能打开!\n\007"); return; } encryptchar(); writedat();}int readdat()//读取文件数据的函数;{ FILE *fp; int i=0; unsigned 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)*p=0; i++; } maxline=i; fclose(fp); return 0;}void writedat()//写入文件数据的函数;{ FILE *fp; int i; fp=fopen("ps10.dat","w"); for(i=0;i<maxline;i++) printf("%s\n",xx[i]; fprintf(fp,"%s\n",xx[i]);}fclose(fp);}[解决办法]
- C/C++ code
int readdat()//读取文件数据的函数;{ FILE *fp; int i=0; unsigned char *p; if((fp=fopen("eng.in","r"))==NULL) return 1; while(fgets((char *)xx[i],80,fp)!=NULL) { p=(unsigned char *)strchr((char *)xx[i],'\n'); if(p)*p=0; i++; } maxline=i; fclose(fp); return 0;}