编程小问题 20
帮我看看这题的错误应该怎么改:#include<stdio.h>#include<string.h>#include<conio.h>#include<ctype.h>u...
帮我看看这题的错误应该怎么改:#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <ctype.h>
unsigned char xx[50][80];
int maxline=0;/*文章的总行数*/
int ReadDat(void);
void WriteDat(void);
void encryptChar()
{ int i,j;
for(i=0;i<maxline;i++)
for(j=0;j<strlen(xx[i]);j++)
if(xx[i][j]*11%256<=32||xx[i][j]*11%256>='a'&&xx[i][j]*11%256<='z') continue;
else xx[i][j]=xx[i][j]*11%256;
}
void main()
{
if(ReadDat()){
printf("数据文件ENG.IN不能打开!\n\007");
return;
}
encryptChar();
WriteDat();
}
int ReadDat(void)
{
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(void)
{
FILE *fp;
int i;
fp=fopen("ps5.dat","w");
for(i=0;i<maxline;i++){
printf("%s\n",xx[i]);
fprintf(fp,"%s\n",xx[i]);
}
fclose(fp);
}
用C++环境编的,(三级)
--------------------Configuration: sdf - Win32 Debug--------------------
Compiling...
dg.cpp
D:\Program Files\Microsoft Visual Studio\MyProjects\sdf\dg.cpp(15) : error C2664: 'strlen' : cannot convert parameter 1 from 'unsigned char [80]' to 'const char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
D:\Program Files\Microsoft Visual Studio\MyProjects\sdf\dg.cpp(38) : error C2664: 'fgets' : cannot convert parameter 1 from 'unsigned char [80]' to 'char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
D:\Program Files\Microsoft Visual Studio\MyProjects\sdf\dg.cpp(38) : fatal error C1903: unable to recover from previous error(s); stopping compilation
执行 cl.exe 时出错.
sdf.exe - 1 error(s), 0 warning(s)
用C++,但是int ReadDat(void)不能改,看下能调试出来吗,是计算机三级的 展开
#include <string.h>
#include <conio.h>
#include <ctype.h>
unsigned char xx[50][80];
int maxline=0;/*文章的总行数*/
int ReadDat(void);
void WriteDat(void);
void encryptChar()
{ int i,j;
for(i=0;i<maxline;i++)
for(j=0;j<strlen(xx[i]);j++)
if(xx[i][j]*11%256<=32||xx[i][j]*11%256>='a'&&xx[i][j]*11%256<='z') continue;
else xx[i][j]=xx[i][j]*11%256;
}
void main()
{
if(ReadDat()){
printf("数据文件ENG.IN不能打开!\n\007");
return;
}
encryptChar();
WriteDat();
}
int ReadDat(void)
{
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(void)
{
FILE *fp;
int i;
fp=fopen("ps5.dat","w");
for(i=0;i<maxline;i++){
printf("%s\n",xx[i]);
fprintf(fp,"%s\n",xx[i]);
}
fclose(fp);
}
用C++环境编的,(三级)
--------------------Configuration: sdf - Win32 Debug--------------------
Compiling...
dg.cpp
D:\Program Files\Microsoft Visual Studio\MyProjects\sdf\dg.cpp(15) : error C2664: 'strlen' : cannot convert parameter 1 from 'unsigned char [80]' to 'const char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
D:\Program Files\Microsoft Visual Studio\MyProjects\sdf\dg.cpp(38) : error C2664: 'fgets' : cannot convert parameter 1 from 'unsigned char [80]' to 'char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
D:\Program Files\Microsoft Visual Studio\MyProjects\sdf\dg.cpp(38) : fatal error C1903: unable to recover from previous error(s); stopping compilation
执行 cl.exe 时出错.
sdf.exe - 1 error(s), 0 warning(s)
用C++,但是int ReadDat(void)不能改,看下能调试出来吗,是计算机三级的 展开
1个回答
展开全部
我也是初学啊,说错了别骂我
for(i=0;i<maxline;i++)
for(j=0;j<strlen(xx[i]);j++)
if(xx[i][j]*11%256<=32||xx[i][j]*11%256>='a'&&xx[i][j]*11%256<='z') continue;
else xx[i][j]=xx[i][j]*11%256;
for循环的{}对吗?不用把if...else...括上?
for(i=0;i<maxline;i++)
for(j=0;j<strlen(xx[i]);j++)
if(xx[i][j]*11%256<=32||xx[i][j]*11%256>='a'&&xx[i][j]*11%256<='z') continue;
else xx[i][j]=xx[i][j]*11%256;
for循环的{}对吗?不用把if...else...括上?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询