Re: Mixing size_t and other types

On 08/ 1/10 09:31 PM, Navaneeth wrote:

I have a variable

long int size;

Value of this variable will be the size of a file which I am trying to
load into memory. Now I need to allocate memory using malloc. If I


compiler warns about "conversion to ‘size_t’ from ‘long int’ may
change the sign of the result". So I added an explicit cast like

malloc((size_t) size);

I am not sure that this is the correct approach. Is this casting OK?
How can I find out the value of size_t?

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.

Ian Collins