今天在测试一段程序的时候,程序简单如下:
int shouldoplen ;
char filebuf[MAXFILESIZE];
int fd = open(logName,O_RDWR);
if(fd<0)
{
writelog(LOG_ERR,"%s,%d,[client] open the file %s error !\n",__FILE__,__LINE__,logName);
exit(-1);
}
filelen = lseek(fd,0,SEEK_END);
readlen = read( fd,filebuf,shouldoplen );
出现的问题是:readlen返回值为0 ,最后找到原因是shouldoplen没有赋值导致的。