strlen in 2d array

Nov 5, 2011 at 9:21pm
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????
Nov 5, 2011 at 11:55pm
closed account (D80DSL3A)
length = strlen( arr[0] );
Nov 6, 2011 at 12:32am
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 Nov 6, 2011 at 12:34am
Topic archived. No new replies allowed.