M
Martin
Hi,
I am trying to write a quick program to access data from a large file
(3238400000), so I intended to use fseek to move around it. However I
can't even open a file pointer and for the life of me I can't spot the
problem. I end up with NULL being returned by fopen! Any thoughts
would be appreciated.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv)
{
FILE *f;
char fn[2000];
strcpy(fn,"/some_place/somefile.bin");
if ((f = fopen(fn, "rb")) == NULL) {
fprintf(stderr, "%s: couldn't open file %s for read\n", argv
[0], fn);
exit(1)
}
fclose(f);
return (0);
}
The only thing I could think of was that perhaps it was because the
file wasn't in my data area, but I checked the permissions and they
seemed ok? And I copied the file local to my directory and that didn't
change things.
ls -l /some_file/someplace.bin
-rw-r----- 1 someone global 3238400000 Jun 4 19:13 /some_file/
someplace.bin
Many thanks,
Martin
I am trying to write a quick program to access data from a large file
(3238400000), so I intended to use fseek to move around it. However I
can't even open a file pointer and for the life of me I can't spot the
problem. I end up with NULL being returned by fopen! Any thoughts
would be appreciated.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv)
{
FILE *f;
char fn[2000];
strcpy(fn,"/some_place/somefile.bin");
if ((f = fopen(fn, "rb")) == NULL) {
fprintf(stderr, "%s: couldn't open file %s for read\n", argv
[0], fn);
exit(1)
}
fclose(f);
return (0);
}
The only thing I could think of was that perhaps it was because the
file wasn't in my data area, but I checked the permissions and they
seemed ok? And I copied the file local to my directory and that didn't
change things.
ls -l /some_file/someplace.bin
-rw-r----- 1 someone global 3238400000 Jun 4 19:13 /some_file/
someplace.bin
Many thanks,
Martin