Hey all,
Can anyone help me figure out why I'm getting the following error: "fseek in do_this:Illegal seek"?
Code:
void do_this(int file)
{
char c;
int disp = 0; //number of char read during this call
int lines_read = 0; //number of lines read during this call
if (lseek(file, pos, SEEK_SET) == -1);
{
int errNum = errno;
display("lseek in do_this:");
disp_err_msg(errNum);
}
while((pos <= file_size) && (pos > -1) && (lines_read <20))
{
if(read(file, &c, 1) == -1)
{
int errNum = errno;
display("read in do_this:");
disp_err_msg(errNum);
}
if (c == '\n')
lines_read++;
pos++;
disp++;
if(write(1, &c, 1) == -1)
{
int errNum = errno;
display("write in do_this:");
disp_err_msg(errNum);
}
}
}
Of course, pos is a global variable...
Thanks!