previous | start | next

String Length

        #include <cstring>
        int strlen(const char *s);
     

Example:

int main()
{
  char s1[4] = {'C', 'a', 't', '\0'};
  int length;

  length = strlen(s1);
  cout << s1 << endl;
  cout << "length = " << length << endl;

}
Output: 3 (not 4)


previous | start | next