On Linux machine,getting some time error in seek from lseek64() method.But after some time on same offset it is not giving any error and working fine.In this case lseek64() method is returning -1.We have our own c library also.Now we are using two library one for read/write on disk and another for capturing block change information using our own library.Two library can create problem?
Asked
Active
Viewed 340 times
0
-
paste the error, share some code, improve the question, to get answer.. – loxxy Oct 12 '12 at 06:46
1 Answers
1
You can use perror("Reason:");
. This will give you some idea where the issue is.
i.e After lseek64() call, use perror().
/* Demonstration of error handling with perror() and errno. */
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
int main()
{
FILE *fp;
char filename[80];
printf("Enter filename: ");
gets(filename);
if (( fp = fopen(filename, "r")) == NULL)
{
perror("You goofed!");
printf("errno = %d.\n", errno);
exit(1);
}
else
{
puts("File opened for reading.");
fclose(fp);
}
return 0;
}

Jeyaram
- 9,158
- 7
- 41
- 63
-
How can we write the output of perror to a buffer and print it later on? – sunmoon Oct 12 '12 at 06:59
-
http://stackoverflow.com/questions/5483120/redirect-perror-output-to-fprintfstderr ... I never tried... May be it will helps you. – Jeyaram Oct 12 '12 at 07:01
-
-