Re: Help ! how to get a file size larger than 2G?
- From: "Joachim Schmitz" <nospam.jojo@xxxxxxxxxxxxxxxxxx>
- Date: Sun, 30 Sep 2007 20:13:43 +0200
"Richard" <rgrdev@xxxxxxxxx> schrieb im Newsbeitrag
news:3455t4-97h.ln1@xxxxxxxxxxxxxxxxxxxxxx
santosh <santosh.k83@xxxxxxxxx> writes:And exactly that missing "#include <stdio.h>" is causing undefined behaviour
karthikbalaguru wrote:
On Sep 30, 1:06 pm, CBFalconer <cbfalco...@xxxxxxxxx> wrote:
zou wrote:
there is a file which is very large,
we can use stat to get a file size(<2G),
struct stat buf;
stat("file", &buf);
long s=(long)stat.st_size;
but stat::st_size is type of off_t(typedef long),
so how about a file larger than 2G?
stat and off_t are not part of standard C and thus off-topic here.
Find a newsgroup dealing with your system, possibly
comp.unix.programmer.
It looks like this function is only available to Unix systems.
I think, you can check with the man page of stat.
C version of code ;-)
Refer this link -
http://www.phim.unibe.ch/comp_doc/c_manual/C/EXAMPLES/stat.c
#include <sys/stat.h> /* declare the 'stat' structure */
struct stat stat_p; /* 'stat_p' is a pointer to a structure
* of type 'stat'. */
if ( -1 == stat (filename, &stat_p))
{
printf(" Error occoured attempting to stat %s\n", filename);
exit(0);
}
printf("File size is %d bytes\n", stat_p.st_size);
Please attempt, wherever possible, to provide correct and compilable
code.
The above code fragment, besides being uncompilable, is also not correct,
in that it invokes undefined behaviour in at least one place.
Since the undefined behaviour is nothing to so with stat, as such,
possibly you could explain? Surely not all "samples" that people post
where they are having difficulties need to be sanitised?!?!? At first
glance all I see really wrong is the comment about stat_p being a pointer.
It
isn't. And of course the lack of an include for printf.
(varadic function without prototype).
Bye, Jojo
.
- Follow-Ups:
- Re: Help ! how to get a file size larger than 2G?
- From: Richard
- Re: Help ! how to get a file size larger than 2G?
- References:
- Help ! how to get a file size larger than 2G?
- From: zou
- Re: Help ! how to get a file size larger than 2G?
- From: CBFalconer
- Re: Help ! how to get a file size larger than 2G?
- From: karthikbalaguru
- Re: Help ! how to get a file size larger than 2G?
- From: santosh
- Re: Help ! how to get a file size larger than 2G?
- From: Richard
- Help ! how to get a file size larger than 2G?
- Prev by Date: Re: Should we broaden the topicality of this group?
- Next by Date: Re: Warnings in lcc-win
- Previous by thread: Re: Help ! how to get a file size larger than 2G?
- Next by thread: Re: Help ! how to get a file size larger than 2G?
- Index(es):
Relevant Pages
|