#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <dir.h>
struct displaydata
{
char strflag[5];
char strval[15];
} heatqty = {"6.8(",'\0'}, cvolume = {"6.26(",'\0'};
int searchdata( struct dispalydata *disp , char *filename)
{
FILE *fp;
char buf[256] , *p , c;
int c_offset = 0;
char *pt1,*pt2;
if((fp = fopen(filename,"rb") )== NULL){
printf("file open error!\n");
return 0;
}
while(!feof(fp)){
fread(buf,1,256,fp);
p = strstr( buf, "\r\r\n" );
if( p == NULL ){
printf("string end error\n");
}
*p = '\0';
c_offset = p - buf + c_offset + 1;
fseek(fp,c_offset,0);
//puts(buf);
pt1 = strstr(buf , (*disp).strflag);
if ( pt1 != NULL)
{
pt2 = strchr(pt1,')') ;
*pt2 = '\0';
strcpy( (*disp).strval , (pt1 + strlen( (*disp).strflag)) );
fclose(fp);
return 1;
}
}
fclose(fp);
return 0;
}
int main()
{
char *qty ;
char *file1 = "C:\\design\\TEMP";
struct displaydata *dpt = &heatqty;
int ret ;
clrscr();
ret = searchdata( dpt , file1 );
if (ret == 1)
printf("heatqty = %s",heatqty.strval);
getch();
return 1;
}
以上是我编的一个小程序,开始就定义了struct displaydata,其中strflag[5] 和 strval[15] 是结构体displaydata的成员,在子程序int searchdata( struct dispalydata *disp , char *filename)中,把该结构体作为它的一个参数,但在编译时却总是报错:strflag 和 strval没有定义,disp没有使用过.
明明前面定义了,为什么还报错说我没有的定义呢?
报错信息:
Error ..\..\DESIGN\TEST2.C 39: Undefined symbol 'strflag'
Error ..\..\DESIGN\TEST2.C 44: Undefined symbol 'strval'
Error ..\..\DESIGN\TEST2.C 44: Undefined symbol 'strflag'
Warning ..\..\DESIGN\TEST2.C 54: Parameter 'disp' is never used
Warning ..\..\DESIGN\TEST2.C 67: Suspicious pointer conversion
我用的编译器时BORLANDC
请教了几位高手都没有看出来,哪位大侠来帮我看看