I want to detect the last element of an array of integer in C code. Otherwise i need to stop handling array data when the array element is empty. really my array have a maximum size fixed and it was filled from an external file so i dont know when it stop filling the array.
Last element is in position
sizeof(array)/sizeof(array[0]) - 1
There is no defined term as empty array
Your array will always hold some value even if you dont initialize it explicitly
You need to define in your application how will you term it as empty may be by considering if its(element of array) value is 0 or some other value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With