For example a code like:
int arr[5] = {1, 2, 3, 4, 5}
Is there anyway to get the 5 in arr[5]? I haven't learnt C++ before.
For example a code like:
int arr[5] = {1, 2, 3, 4, 5}
Is there anyway to get the 5 in arr[5]? I haven't learnt C++ before.
You can get it by getting the array size and divide it by the size of a single element:
int arr[5] = {1, 2, 3, 4, 5};
size_t lengthOfArr = sizeof(arr)/sizeof(arr[0]) ;