Hello all!
I have come on to a problem for which I am not able to find a solution
searching the web.
What I am trying to do is reading a log-file with a size of 1.3 GB.
When reading it using fread() or the Visual C specific(?) read() they
return that the number of bytes read equals the number of bytes
requested, however all of the bytes read turn out to have a value of
zero (the file contains other values). When using the exact same code
on a much smaller file (1 MB) it works fine.
char filename[] = "c:/temp/data2000.dat";
char buffer[40];
FILE *file_d;
struct _stat stat_buf;
int fd;
int file_exists;
long file_size;
//Returns true:
file_exists = (_stat(filename ,&stat_buf)== 0) && (stat_buf.st_mo de &
S_IFREG);
//Returns 1328000000 (actual filesize):
file_size = (file_exists) ? stat_buf.st_siz e : -1;
//Booth returns values <> NULL and -1:
//file_d = fopen(filename, "r");
fd = open(filename, _O_RDONLY);
//Both returns 40:
//bytes_read = fread(buffer, 1, sizeof(buffer), file_d);
bytes_read = read(fd, buffer, 40);
//fclose(file_d);
close(fd);
Greatful for any ideas!
Best regards