Write a program that displays length of each name stored in a 2D character array. You may
assume that 10 names are being stored in the 2D character array at a given time and the
length of the name may not exceed 30 charatcers.

If you are allowed to assume that these are C-style strings that will use a zero value to mark the end, the function you're looking for is strlen.

We are not allowed to use strlen function. . :/

Do you know how to look at the chars in the array?

We are not allowed to use strlen function. . :/

So ... can you code your own (safe) version of a 'strlen' function?

size_t mySafeStrLen( const char* strIn )
{
   size_t len = 0;
   if( strIn )
   {  
      const char* p = strIn;
     // rest of your code goes here
     //len = p-strIn; // using pointer arithmetic //
   }
   return len;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.