text: user4456: I write under code but I can't run it when I run by g++ . erro is about  strlen.
  errors: 
  a.cpp: In function ‘bool checker(char*, int)’:
  a.cpp:185:26: error: ‘str’ is not a member of ‘std’
   185 |  for(int i = 0; i < std::str.length(word); i++)
    |                          ^~~
  a.cpp: In function ‘int status(char*, int, int)’:
  a.cpp:192:40: error: ‘str’ is not a member of ‘std’
     192 |  for(int i = 0; i < 4 && nw*4+i < std::str.length(pmt[pn]); i++)
    |                                        ^~~
  a.cpp:199:10: error: ‘str’ is not a member of ‘std’
    199 |  if(std::str.length(pmt[pn]) > nw*4)
    |          ^~~
  a.cpp: In function ‘int main()’:
  a.cpp:225:22: error: ‘str’ is not a member of ‘std’
    225 |     len_words = std::str.length(pmt[i])/2;
      |                      ^~~
  
  
  user961: I think you're confusing C++ and C strings, which are very different. When you have a char *, that's a C-style "string". It's really just a bunch of bytes with a zero byte at the end, demarcating the end of the string. To find the length of a C string you include <cstring> (or <string.h> in C) and call strlen, like this:
  /** Print every character in the string */
  void print_chars_in_string(char* word) {
      for (size_t i = 0; i < strlen(word); ++i) {
          putchar(word[i]);
      }
  }
  
  strlen is actually pretty simple though, you can write your own version as an academic exercise like this:
  size_t deluxe_bespoke_strlen(char* str) {
      size_t length = 0;
  
      while (*str++)
          ++length;
  
      return length;
  }
  
  Since the while-loop condition will be true until you hit the null terminator (the zero byte at the end), this is how you would implement the strlen function without a for-loop, otherwise you would need the strlen function for the strlen function.
  In C++, strings are actual objects, with methods you can call. To get the length of a C++ string simply do this:
  std::string my_name = "Jose";
  std::cout << my_name.length() << std::endl;
  
  If you have a C string, you can convert it to a C++ string with the built-in constructor:
  const char* my_name = "Jose";
  std::string my_name_cppstring = std::string(my_name);
  
  You can also get the C version of a C++ string by calling the c_str() member function like this:
  std::string sequence = "GATTACA";
  size_t length = strlen(sequence.c_str());
  
  My recommendation is to not mix C and C++. C is my favorite programming language, but that doesn't mean everyone should write everything in C. Since you're using C++ I'm guessing that's your preference, so I would suggest using C++ strings instead of C strings, just remember to include <string>.
  
  As for your specific question, the compiler is giving you the correct message: str is not a member of std. You don't add the namespace to variables. This is how that works:
  #include <cstdlib>
  #include <iostream>
  
  namespace CustomDeluxeBespokeStandardNamespace
  {
      size_t custom_bespoke_strlen(char* str)
      {
          size_t length = 0;
  
          while (*str++)
              ++length;
  
          return length;
      }
  }
  
  int main(int argc, char *argv[])
  {
      if (argc == 1) {
          std::cerr << "No input(s)." << std::endl;
          std::exit(EXIT_FAILURE);
      }
  
      while (*++argv) {
          std::cout << *argv << ": " << CustomDeluxeBespokeStandardNamespace::custom_bespoke_strlen(*argv) << std::endl;
      }
  }
  
  So if you run it like this:
  testprogram horse house mouse cat
  
  You should get this output:
  horse: 5
  house: 5
  mouse: 5
  cat: 3
  
  So to recap, you were adding the namespace to your variables, and the compiler was giving you an error because it correctly could not find anything by that name in the std namespace. Even if it had though, C style strings do not have member functions. There are no such things as objects in C, at least not in the sense that you can define member functions for an object, so that was the second error.
  
  As an aside, you will note all my examples using strlen both custom and actual return size_t. This is not an accident; in both C and C++ the return type of a call to strlen is size_t. You have to be careful because in your code you compare an int to a size_t. Comparing a signed value to an unsigned value is Not Good because it will work only if the signed value can be faithfully represented after a conversion to an unsigned value. If it can't though, you're in for a bad time.
  
original_text: 4456: <p>I write under code but I can't run it when I run by g++ . erro is about  strlen.<br>
  errors: </p>
  
  <pre><code>a.cpp: In function ‘bool checker(char*, int)’:
  a.cpp:185:26: error: ‘str’ is not a member of ‘std’
   185 |  for(int i = 0; i &lt; std::str.length(word); i++)
    |                          ^~~
  a.cpp: In function ‘int status(char*, int, int)’:
  a.cpp:192:40: error: ‘str’ is not a member of ‘std’
     192 |  for(int i = 0; i &lt; 4 &amp;&amp; nw*4+i &lt; std::str.length(pmt[pn]); i++)
    |                                        ^~~
  a.cpp:199:10: error: ‘str’ is not a member of ‘std’
    199 |  if(std::str.length(pmt[pn]) &gt; nw*4)
    |          ^~~
  a.cpp: In function ‘int main()’:
  a.cpp:225:22: error: ‘str’ is not a member of ‘std’
    225 |     len_words = std::str.length(pmt[i])/2;
      |                      ^~~
  </code></pre>
   961: <p>I think you're confusing C++ and C strings, which are very different. When you have a <code>char *</code>, that's a C-style "string". It's really just a bunch of bytes with a zero byte at the end, demarcating the end of the string. To find the length of a C string you include <code>&lt;cstring&gt;</code> (or <code>&lt;string.h&gt;</code> in C) and call <code>strlen</code>, like this:</p>
  
  <pre><code>/** Print every character in the string */
  void print_chars_in_string(char* word) {
      for (size_t i = 0; i &lt; strlen(word); ++i) {
          putchar(word[i]);
      }
  }
  </code></pre>
  
  <p><code>strlen</code> is actually pretty simple though, you can write your own version as an academic exercise like this:</p>
  
  <pre><code>size_t deluxe_bespoke_strlen(char* str) {
      size_t length = 0;
  
      while (*str++)
          ++length;
  
      return length;
  }
  </code></pre>
  
  <p>Since the while-loop condition will be true until you hit the null terminator (the zero byte at the end), this is how you would implement the strlen function without a for-loop, otherwise you would need the strlen function for the strlen function.</p>
  
  <p>In C++, strings are actual objects, with methods you can call. To get the length of a C++ string simply do this:</p>
  
  <pre><code>std::string my_name = "Jose";
  std::cout &lt;&lt; my_name.length() &lt;&lt; std::endl;
  </code></pre>
  
  <p>If you have a C string, you can convert it to a C++ string with the built-in constructor:</p>
  
  <pre><code>const char* my_name = "Jose";
  std::string my_name_cppstring = std::string(my_name);
  </code></pre>
  
  <p>You can also get the C version of a C++ string by calling the <code>c_str()</code> member function like this:</p>
  
  <pre><code>std::string sequence = "GATTACA";
  size_t length = strlen(sequence.c_str());
  </code></pre>
  
  <p>My recommendation is to not mix C and C++. C is my favorite programming language, but that doesn't mean everyone should write everything in C. Since you're using C++ I'm guessing that's your preference, so I would suggest using C++ strings instead of C strings, just remember to include <code>&lt;string&gt;</code>.</p>
  
  <hr />
  
  <p>As for your specific question, the compiler is giving you the correct message: <code>str</code> is not a member of <code>std</code>. You don't add the namespace to variables. This is how that works:</p>
  
  <pre><code>#include &lt;cstdlib&gt;
  #include &lt;iostream&gt;
  
  namespace CustomDeluxeBespokeStandardNamespace
  {
      size_t custom_bespoke_strlen(char* str)
      {
          size_t length = 0;
  
          while (*str++)
              ++length;
  
          return length;
      }
  }
  
  int main(int argc, char *argv[])
  {
      if (argc == 1) {
          std::cerr &lt;&lt; "No input(s)." &lt;&lt; std::endl;
          std::exit(EXIT_FAILURE);
      }
  
      while (*++argv) {
          std::cout &lt;&lt; *argv &lt;&lt; ": " &lt;&lt; CustomDeluxeBespokeStandardNamespace::custom_bespoke_strlen(*argv) &lt;&lt; std::endl;
      }
  }
  </code></pre>
  
  <p>So if you run it like this:</p>
  
  <pre><code>testprogram horse house mouse cat
  </code></pre>
  
  <p>You should get this output:</p>
  
  <pre><code>horse: 5
  house: 5
  mouse: 5
  cat: 3
  </code></pre>
  
  <p>So to recap, you were adding the namespace to your variables, and the compiler was giving you an error because it correctly could not find anything by that name in the <code>std</code> namespace. Even if it had though, C style strings do not have member functions. There are no such things as objects in C, at least not in the sense that you can define member functions for an object, so that was the second error.</p>
  
  <hr />
  
  <p>As an aside, you will note all my examples using <code>strlen</code> both custom and actual return <code>size_t</code>. This is not an accident; in both C and C++ the return type of a call to <code>strlen</code> is <code>size_t</code>. You have to be careful because in your code you compare an <code>int</code> to a <code>size_t</code>. Comparing a signed value to an unsigned value is <a href="https://stackoverflow.com/questions/5416414/signed-unsigned-comparisons">Not</a> <a href="https://softwareengineering.stackexchange.com/questions/175253/why-does-an-unsigned-int-compared-with-a-signed-character-turn-out-with-an-unexp">Good</a> because it will work only if the signed value can be faithfully represented after a conversion to an unsigned value. If it can't though, you're in for a bad time.</p>
  