电视剧生生世世图片:c的这段程序,那点错拉!

来源:百度文库 编辑:中科新闻网 时间:2024/04/28 01:49:33
#include<stdio.h>
#include<string.h>
#include<conio.h>

char xx[20][80];

void jsSort()
{

}

void main()
{
readDat();
jsSort();
writeDat();
}

readDat()
{
FILE *in;
int i=0;
char *p;

in=fopen("in.dat","r");
while(i<20&&fgets(xx[i],80,in)!=NULL){
p=strchr(xx[i],'\n');
if(p)*p=0;
i++;
}
fclose(in);
}

writeDat()
{
FILE *out();
int i;
clrscr();
out=fopen("out.dat","w");
for(i=0;i<20;i++){
printf(\"%s\n",xx[i]);
fprintf(out,"%s\n",xx[i]);
}
fclose(out);
}

我编译的时候,老是提示36行不对!到底这么回事?

你这程序何止一个错, 我改了下,可以通过编译

#include <stdio.h>
#include <string.h>
#include <conio.h>

char xx[20][80];

void jsSort()
{

}

void readDat()
{
FILE *in;
int i=0;
char *p;

in=fopen("in.dat","r");
while(i<20&&fgets(xx[i],80,in)!=NULL){
p=strchr(xx[i],'\n');
if(p)*p=0;
i++;
}
fclose(in);
}

void writeDat()
{
FILE *out;
int i;
/*clrscr(); */
out=fopen("out.dat","w");
for(i=0;i<20;i++){
printf("%s\n",xx[i]);
fprintf(out,"%s\n",xx[i]);
}
fclose(out);
}

void main()
{
readDat();
jsSort();
writeDat();
}

1。printf(\"%s\n",xx[i]); 改为printf("%s\n",xx[i]);
2。把main函数放到最后或声明函数

这应该是C上机的题吧,jsSort()这个函数是你要按要求编写内容的,不能为空啊。其他的是用来读文件和写文件的,可以不用管,只要把那个函数写对就可以了。错误可能是程序要求的文件不在,所以无法读出。