M
Malcolm McLean
2GB ought to be enough for anyone. What sort of data are youSome maybe, but not half!
processing?
2GB ought to be enough for anyone. What sort of data are youSome maybe, but not half!
2GB ought to be enough for anyone. What sort of data are you
processing?
Barry Schwarz said:[email protected] said:Strangely enough, size_t is commonly used for sizes, so just make size a
size_t and save to agro.
size_t will be an unsigned type.
Thanks. But this variable holds a value that comes from the standard
function "ftell". It'd be something like,
fseek (fp , 0 , SEEK_END);
size = ftell (fp); /* ftell gives me long int. */
rewind (fp);
So I think I won't be able to make it a size_t. Not sure how to go
about this. Any help?
You mustn't assign the return value of 'ftell' to a variable of type
'size_t' because it may return -1L on error. In that case you'd end up
with a nonsensical file position value, [snip]
Right in the sense that the type 'size_t' can be too narrow,
but 'unsigned long' should work just fine, since 'ftell()'
returns a plain 'long'. The error indicator value of -1
can be tested for in an 'unsigned long size' using a regular
equality comparison (ie, == or !=).
How does one distinguish between the error return of -1L (which is
converted to ULONG_MAX) and the actual return of ULONG_MAX?
<--
I agree with you up to a point, but it is still prudent when designing
a small car to document in the driver's handbook that it wasn't
intended for elephants and design the doors to debar elephants -
rather than unexpectedly turning itself inside out or destroying the
universe when the first elephant tries to climb aboard.
-->
by this reasoning, no one could use pointers without first checking they
weren't NULL either...
faster and easier in most cases is to assume that the pointers are not NULL,
and only really bother with checking in cases where a NULL is a reasonably
expected result...
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.