title: C++ error "not all control paths return a value"
body: <p>I am trying to output the reverse of a string by calling a function. I think there is something wrong with my reverse function.
  I keep getting the error "not all control paths return a value."</p>
  
  <pre><code>#include&lt;iostream&gt;
  
  using std::cout;
  using std::endl;
  using std::cin;
  int LengthofString(    char *); // declaring prototype for length of the string 
  int ReverseD(char *);
  
  int main()
  {
      char string1[100];
      cout&lt;&lt;"Enter a string: ";
      cin&gt;&gt;string1;
  
      cout&lt;&lt;"Length of string is "&lt;&lt;LengthofString(string1)&lt;&lt;endl&lt;&lt;ReverseD(string1)&lt;&lt;endl;
  
      system("PAUSE");
      return 0;
  }
  
  int LengthofString(   char *x)
  {
      int index;
      for(index = 0; *x!='\0';x++,index++);
  
      return index;
  }
  
  int reverse(char* y)
  {
    int ii, n;
    n = LengthofString(y); 
    for(ii=0; ii&lt;n/2;ii++) {
      char temp;
      temp = y[ii];
      y[ii] = y[n - ii - 1];
      y[n - ii] = temp;
      return temp;
    }
  }
  </code></pre>