Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
If the array is statically defined:
int alpha[100];
alpha[99]=4242;
const int last = alpha [ (sizeof(alpha) / sizeof(alpha[0]))-1];
Nothing, if you don't mark it.
To do this, in char-strings ("C-strings", "zero-terminated strings"), an element with a value '\0'
(null character) is added to the end, on the presence of which standard functions rely, like strlen(const char*)
, which counts characters up to the first zero-terminator.
ZY Theoretically, there is still some allocation header, which is located before the dynamically allocated (that is, only in the heap) buffer, which is oriented free(void*)
to, but this is not regulated by the standard in any way.
UPD: Since C++11 we have std::array
, which actually wraps a buffer in an object.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question