N
Navaneeth
Hello,
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
write
malloc(size);
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?
Any help would be great!
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
write
malloc(size);
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?
Any help would be great!