title: can't get length of string in vc++
body: <p>I want to retrive files with extension of .jpg from directory in vc++ 08. I'm not much comfortable with pointers so I got error when I try to get length of string in following code. Can anyone help me out?? </p>
  
  <p>Here is my code..</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include &lt;string&gt;
  #pragma warning( disable : 4996 )
  #include "dirent.h"
  #pragma warning( default : 4996 )
  using namespace std;
  
  int main(int argc, char *argv[])
  {
  if(argc != 2)
  {
    cout&lt;&lt;"Usage: "&lt;&lt;argv[0]&lt;&lt;" &lt;Directory name&gt;"&lt;&lt;endl;
    return -1;
  }
  
  DIR *dir;
  dir = opendir (argv[1]);
  if (dir != NULL)
  {
      string name; string ext = ".jpg"; int len;
  
    cout&lt;&lt;"Directory Listing for "&lt;&lt;argv[1]&lt;&lt;" : "&lt;&lt;endl;
    struct dirent *ent;
    while ((ent = readdir (dir)) != NULL)
    {
      name = ent-&gt;d_name; 
      len = name.length;                  // here i got error...
      name = name.substr(0, len-4);
  
      if(_stricmp(name.c_str(), ext.c_str()) == 0)
      {
          cout&lt;&lt;ent-&gt;d_name&lt;&lt;endl;
      }
      else
      {
          cout&lt;&lt;"No JPG file"&lt;&lt;endl;
      }
    }
  }
  else
  {
    cout&lt;&lt;"Invalid Directory name"&lt;&lt;endl;
    return -1;
  }
  
  return 0;
  }
  </code></pre>
  
  <p>And error is  </p>
  
  <pre><code>example.cpp(29) : error C3867: 'std::basic_string&lt;_Elem,_Traits,_Ax&gt;::length': function call missing argument list; use '&amp;std::basic_string&lt;_Elem,_Traits,_Ax&gt;::length' to create a pointer to member
  1&gt;        with
  1&gt;        [
  1&gt;            _Elem=char,
  1&gt;            _Traits=std::char_traits&lt;char&gt;,
  1&gt;            _Ax=std::allocator&lt;char&gt;
  1&gt;        ]
  1&gt;\example.cpp(29) : error C2440: '=' : cannot convert from 'unsigned int (__thiscall std::basic_string&lt;_Elem,_Traits,_Ax&gt;::* )(void) const' to 'int'
  1&gt;        with
  1&gt;        [
  1&gt;            _Elem=char,
  1&gt;            _Traits=std::char_traits&lt;char&gt;,
  1&gt;            _Ax=std::allocator&lt;char&gt;
  1&gt;        ]
  1&gt;        There is no context in which this conversion is possible
  </code></pre>
  
  <p>Thanks in advance...</p>