error C2664: 'fgets' : cannot convert parameter 1 from 'unsigned char [80]' to 'char *'
原程序为#include<stdlib.h>#include<stdio.h>#include<string.h>#include<ctype.h>unsignedcha...
原程序为#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<ctype.h>
unsigned char xx[50][80];
int maxline=0;/*文章的总行数*/
int ReadDat(void);
void WriteDat(void);
void encryptChar()
{
}
void main()
{
system("CLS");
if(ReadDat())
{
printf("数据文件ENG4.IN不能打开!\n\007");
return ;
}
encryptChar();
WriteDat();
}
int ReadDat(void)
{
FILE *fp;
int i=0;
unsigned char *p;
if((fp=fopen("ENG4.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("ps4.DAT","w");
for(i=0;i<maxline;i++)
{
printf("%s\n",xx[i]);
fprintf(fp,"%s\n",xx[i]);
}
fclose(fp);
}
进行调试时显示题目上的错误,请高手帮忙 展开
#include<stdio.h>
#include<string.h>
#include<ctype.h>
unsigned char xx[50][80];
int maxline=0;/*文章的总行数*/
int ReadDat(void);
void WriteDat(void);
void encryptChar()
{
}
void main()
{
system("CLS");
if(ReadDat())
{
printf("数据文件ENG4.IN不能打开!\n\007");
return ;
}
encryptChar();
WriteDat();
}
int ReadDat(void)
{
FILE *fp;
int i=0;
unsigned char *p;
if((fp=fopen("ENG4.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("ps4.DAT","w");
for(i=0;i<maxline;i++)
{
printf("%s\n",xx[i]);
fprintf(fp,"%s\n",xx[i]);
}
fclose(fp);
}
进行调试时显示题目上的错误,请高手帮忙 展开
1个回答
展开全部
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<ctype.h>
char xx[50][80];
char (*px)[50];
int maxline=0;/*文章的总行数*/
int ReadDat(void);
void WriteDat(void);
void encryptChar()
{
}
void main()
{
system("CLS");
if(ReadDat())
{
printf("数据文件ENG4.IN不能打开!\n\007");
return ;
}
encryptChar();
WriteDat();
}
int ReadDat(void)
{
FILE *fp;
int i=0;
char *p;
if((fp=fopen("ENG4.IN","r"))==NULL)
return 1;
while(fgets(*(px+i),80,fp)!=NULL)
{
p = strchr(*(px+i),'\n');
if (p)
*p=0;
i++;
}
maxline=i;
fclose(fp);
return 0;
}
void WriteDat(void)
{
FILE *fp;
int i;
fp=fopen("ps4.DAT","w");
for(i=0;i<maxline;i++)
{
printf("%s\n",xx[i]);
fprintf(fp,"%s\n",xx[i]);
}
fclose(fp);
}
#include<stdio.h>
#include<string.h>
#include<ctype.h>
char xx[50][80];
char (*px)[50];
int maxline=0;/*文章的总行数*/
int ReadDat(void);
void WriteDat(void);
void encryptChar()
{
}
void main()
{
system("CLS");
if(ReadDat())
{
printf("数据文件ENG4.IN不能打开!\n\007");
return ;
}
encryptChar();
WriteDat();
}
int ReadDat(void)
{
FILE *fp;
int i=0;
char *p;
if((fp=fopen("ENG4.IN","r"))==NULL)
return 1;
while(fgets(*(px+i),80,fp)!=NULL)
{
p = strchr(*(px+i),'\n');
if (p)
*p=0;
i++;
}
maxline=i;
fclose(fp);
return 0;
}
void WriteDat(void)
{
FILE *fp;
int i;
fp=fopen("ps4.DAT","w");
for(i=0;i<maxline;i++)
{
printf("%s\n",xx[i]);
fprintf(fp,"%s\n",xx[i]);
}
fclose(fp);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询