Find integer array size in C programming

Someone asked me once “how can I get integer array size in C programming and use it in the code?”.Unfortunately there is no defined standard function to get that in C.
Rather you could use below method .Suppose you have defined an integer array ( static ) called , int intArray[10];Its size can be derived by,size_t size = sizeof(intArray)/sizeof(intArray[0]);

size_t size = sizeof(intArray) / sizeof(int);
Thats it..

Leave a Reply

Your email address will not be published. Required fields are marked *