0

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.

3
Contributors
4
Replies
12
Views
3 Years
Discussion Span
Last Post by David W
1

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.

0

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;

Edited by David W

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.