title: Error: cannot compare a pointer to integer?
body: <p>This is a program to find the longest word in a string but i have a problem.the compiler said that i cant compare a pointer to integer!but i compare a char pointer to a char in line </p>
  
  <pre><code>#include &lt;string.h&gt;
  #include &lt;string&gt;
  #include &lt;iostream&gt;
  using namespace std;
  
  string longest(char * a)
  {
      int count=0;
      int finalcount=0;
      string longs="";
      string longest;  
      int lena=strlen(a);
      for(int i=0;i&lt;lena;i++)
      {
          if(*a==" ")
          {
              if(count&gt;=finalcount)   
              {
                  finalcount=count;
                  longest=longs;
              }
              count=0;
              longs="";
          }
          else{*a++;count++;longs+=*a;}
      }
      return longest;
  }
  int main()
  {
      char a[]="which is the longest";
      cout&lt;&lt;longest(a);
      return 0;
  }
  </code></pre>