"Imran" <im******@in.bosch.com> wrote in message
news:cf**********@ns1.fe.internet.bosch.com...
Hello All
I have a 2D array,
char arr[4][10] = {"Hello","world","test","hi"};
how can find the strlen of the array
am expecting array length as "4"
Thanks in Adv
Your expected answer indicates that you are really trying to determine the
first dimension of a multi-dimensional array. The strlen function does not
do this. In what context are you trying to determine this? If you're
inside a function, then you may have to pass the first dimension to that
function. For example:
void foo(char (*arr)[10], int size) {
for ( int i = 0; i < size; ++i ) {
std::cout << arr[i] << std::endl;
}
}
int main() {
char arr[4][10] = {"Hello","world","test","hi"};
foo(arr,sizeof(arr)/sizeof(arr[0]));
return 0;
}
--
David Hilsee