这是怎么回事啊?arithmetic on pointer to an incomplete type

fansogoo 2004-03-12 01:21:16
我的程序:
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#define ARGUC 8

size_t readfile_aline(int fd,char buf[],const size_t charlen);
int getIcpInfo(char icp[][],const int count,char *buf);
/*typedef struct icp_info
{
char billkind[4];
char c_icpid[6];
char c_operateid[9];
char vc_name[65];
}icpinfo;*/
int main(int argc,char *argv[])
{
int fd,rec_count,i;
/*size_t count;*/
char icpinfo[ARGUC][65];
char buf[512];
if (argc!=2)
{
printf("parameter error!\n");
return -1;
}
if((fd=open(argv[1],O_RDONLY))==-1)
{
printf("Open file Error\n Error No=%d\n",errno);
return -1;
}
while((long)readfile_aline(fd,buf,sizeof(buf))>0L)
{
printf("the buf is:%s\n",buf);
if(getIcpInfo(icpinfo,ARGUC,buf)!=-1)
/*split the icpinfo string read from the datafile*/
{
if(strcmp(icpinfo[0],"gaa")==0)
rec_count=8;
else if(strcmp(icpinfo[0],"gic")==0)
rec_count=7;
else
continue;
for(i=0;i<rec_count;i++)
printf("record #%i is:%s\n",icpinfo[i]);
}
}
close(fd);
}

size_t readfile_aline(int fd,char buf[],const size_t bufsize)
{
size_t size=0;
char c;
if (bufsize<=1)
{
printf("buffer is too small\n");
buf[bufsize-1]='\0';
return -1;
}
do
{
if (size>=bufsize-1)
{
printf("buffer is full\n");
buf[bufsize-1]='\0';
return -2;
}
if(read(fd,&c,1)==0)
{
printf("file reach the end\n");
buf[size]='\0';
/*printf(" the size is:%ld\n",(long)size);*/
return size-1;
}
else
buf[size]=c;
if (errno==EBADF)
{
printf("the file is not opened\n");
return -3;
}
if(buf[size]=='\n'||buf[size]=='\r')
{
if(buf[size]=='\r')
lseek(fd,1,SEEK_CUR);
buf[size]='\0';
return size-1;

}
size++;

}while(1);
}

int getIcpInfo(char icp[][],const int count,char *buf)
{
char *pdest;
int result,idx=0,i;
char c='|';


while((pdest=strchr(buf,c))!=NULL)
{
result=pdest-buf;
if(idx<=count)
{
for(i=0;i<result;i++)
strncpy(icp[idx],buf,result);
}
else
return -1;
idx++;
buf=buf+result+1;
}
if(idx<=count)
{
i=0;
while(*(buf+i))
{
strcpy(icp[idx],buf);
i++;
}
}
else
return -1;
return 0;/* no error!*/
}


编译结果:
fileread.c: In function `getIcpInfo':
fileread.c:112: arithmetic on pointer to an incomplete type
fileread.c:124: arithmetic on pointer to an incomplete type
...全文
922 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复

23,216

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧