+ 2

HELP..what is the size of int?

if we have an array : int arr[6]; then how many bytes does each element take inside the memory????

19th Dec 2017, 8:56 AM
RiGeL
RiGeL - avatar
3 ответов
+ 7
The size of integer type depends on several factors, size of an int in a 32bit machine differs with 64bit machine, plus compiler also plays a role on the size. The most practical way is to use the sizeof function passing the type name for argument e.g. sizeof(int), this will return number of bytes needed to allocate a variable of the said type. You can use the function for most common types available, including user defined ones. Hth, cmiiw
19th Dec 2017, 9:05 AM
Ipang
+ 4
You're welcome @RiGeL, glad to help : )
19th Dec 2017, 9:16 AM
Ipang
+ 3
@Ipang thank you alot
19th Dec 2017, 9:07 AM
RiGeL
RiGeL - avatar