- 论坛徽章:
- 0
|
运行提示错误:
test.c: In function `main':
test.c:42: `filelist' undeclared (first use in this function)
test.c:42: (Each undeclared identifier is reported only once
test.c:42: for each function it appears in.)
test.c:102: `fileNode' undeclared (first use in t his function)
test.c:138:12: warning: no newline at end of file
请各位大侠帮帮忙,急用!!!
我的程序如下:
#include<stdio.h>;
#include<string.h>;
#include<malloc.h>;
#include<stdlib.h>;
//#include"err_exit.h"
#define BUF_SIZE 40
#define FILE_SIZE sizeof (filelist)
#define Node_SIZE sizeof (fileNode)
#define A 30
#define B 10
#define C 30
#define D 10
#define E 20
struct fileNode
{
char finame[A+1];
char intercode[B+1];
char ftime[C+1];
char fsize[D+1];
char recordCount[E+1];
};
struct filelist
{
struct fileNode *PNode;//指向一条记录
struct filelist *next; //next
};
int main(int argc,char *argv[])
{
FILE *dat;
char buf1[BUF_SIZE],buf2[BUF_SIZE],buf3[BUF_SIZE],buf4[BUF_SIZE],buf5[BUF_SIZE];
int i=0;
int flag=0;
char c;
struct filelist *app,*head,*Temp;
struct fileNode *TempLink;
/*检查参数*/
/*if (argc!=2)
{
printf("usage:a.out<filepathname>;\n" ;
exit(1);
};*/
head=app=(struct filelist *)malloc(FILE_SIZE);//分配链表空间
if((dat=fopen("format.avl","r+" )==NULL)
//err_exit("open failed.\n" ;
{printf("%s","open failed.\n" ;
exit(1);
};
//printf("%s",test.\n" ;
c=fgetc(dat);
while(!feof(dat))
{
i=0;
flag=0;//如果为空,则不读
while ((c!=',')&&(c!='\n'))//读取第一个字段
{
buf1=c;
i++;
c=fgetc(dat);
flag=1;
};
buf1='\0';
c=fgetc(dat);//读取下一个字符
i=0;
while ((c!=',')&&(c!='\n')&&flag)//读取第二个字段
{
buf2=c;
i++;
c=fgetc(dat);
};
buf2='\0';
c=fgetc(dat); //读取下一个字符
i=0;
while ((c!=',')&&(c!='\n')&&flag)//读取第三个字段
{
buf3=c;
i++;
c=fgetc(dat);
};
buf3='\0';
c=fgetc(dat);//读取下一个字符
i=0;
while ((c!=',')&&(c!='\n')&&flag)//读取第四个字段/
{
buf4=c;
i++;
c=fgetc(dat);
};
buf4='\0';
c=fgetc(dat);//读取下一个字符
i=0;
while ((c!='\n')&&flag)//读取第五个字段
{
buf5=c;
i++;
c=fgetc(dat);
};
buf5='\0';
if((c=='\n')&&flag)//在有换行符时取出当前行,然后根据根据输入文件的属性长度取出属性值
{
Temp=(struct filelist *)malloc(FILE_SIZE);//分配链表空间
TempLink=(struct fileNode *)malloc(Node_SIZE);
for(i=0;i<A;i++)
(*TempLink).finame=buf1;
//(*TempLink).finame='\0';
for(i=0;i<B;i++)
(*TempLink).intercode=buf2;
//(*TempLink).intercode='\0';
for(i=0;i<C;i++)
(*TempLink).ftime=buf3;
//(*TempLink).ftime='\0';
for(i=0;i<D;i++)
(*TempLink).fsize=buf4;
//(*TempLink).fsize='\0';
for(i=0;i<E;i++)
(*TempLink).recordCount=buf5;
//(*TempLink).fsize='\0';
Temp->;next=NULL;
Temp-> Node=TempLink;
head->;next=Temp;
head=head->;next ;
}//end if
c=fgetc(dat);
}//end while
head=app->;next;
//测试链表中的数据,将其在屏幕上全部显示出来
while(head!=NULL)
{
printf("%s\n",(head-> Node)->;finame);
printf("%s\n",(head-> Node)->;intercode);
printf("%s\n",(head-> Node)->;ftime);
printf("%s\n",(head-> Node)->;fsize);
printf("%s\n",(head-> Node)->;recordCount);
head=head->;next;
};
return 1;
}//end while |
|