strlen in 2d array
using strlen function how can we find out the length of one string of a 2d array.
|
char arr[][20]={"america", "england", "germany", "france", "europe"};
|
how can I find the length of lets say america here using strlen????
length = strlen( arr[0] );
1 2
|
strlen(*arr); /*for america*/
strlen(*(arr+2)); /*for germany*/
|
to find out all of them:
1 2
|
for (int i = 0; i < 5; ++i)
cout << strlen(*(arr+i));
|
Last edited on
Topic archived. No new replies allowed.