- 论坛徽章:
- 0
|
为什么我的lseek老是出错?请高手指点,谢谢!
错误提示:Invalid argument
代码如下:
#include <stdio.h>
#include <fcntl.h>
#define PATHSIZE 1024
#define BUFFSIZE 1024
int
main()
{
int ret;
int filedes;
ssize_t size;
off_t off;
char pathname[PATHSIZE];
char buf[BUFFSIZE];
strcpy(pathname, "test.txt");
filedes = open(pathname, O_RDONLY);
if(filedes == -1)
{
printf("open fail!\n");
exit(0);
}
// lseek file
off = lseek(filedes, 3, SEEK_CUR);
if(off == -1)
{
printf("lseek error!\n");
perror("lseek");
}
close(filedes);
exit(0);
} |
|