title: reverse a string using pointers
body: <p>I have to admit, i have no idea how to use pointers, but I tried non the less. the problem with my program is that it shows the string in reverse, except for what was the first letter being missing and the entire string is moved one space forward with the first element being blank.
  for example it show " olle" when typing "hello".</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  string reverse(string word);
  
  int main()
  {
  char Cstring[50];
  cout&lt;&lt;"enter a word: ";
  cin&gt;&gt;Cstring;
  string results = reverse(Cstring);
  cout &lt;&lt;results;
  }
  
  string reverse(string word)
  {
      char *front;
      char *rear;
      for (int i=0;i&lt; (word.length()/2);i++)
      {
              front[0]=word[i];
              rear[0]=word[word.length()-i];
              word[i]=*rear;
              word[word.length()-i]=*front;
      }
      return word;
  }
  </code></pre>
  
  <p>The new code works perfectly. changed the strings to cstrings. the question technicaly asked for cstrings but i find strings easier so i work with strings then make the necesary changes to make it c string. figured out ho to initialize the rear and front as well.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstring&gt;
  
  using namespace std;
  
  string reverse(char word[20]);
  
  int main()
  {
  char Cstring[20];
  cout&lt;&lt;"enter a word: ";
  cin&gt;&gt;Cstring;
  string results = reverse(Cstring);
  cout &lt;&lt;results;
  }
  
  string reverse(char word[20])
  {
      char a='a';
      char b='b';
      char *front=&amp;a;
      char *rear=&amp;b;
      for (int i=0;i&lt; (strlen(word)/2);i++)
      {
              front[0]=word[i];
              rear[0]=word[strlen(word)-1-i];
              word[i]=*rear;
              word[strlen(word)-1-i]=*front;
      }
      return word;
  }
  </code></pre>