title: Trimming spaces C++ POINTERS
body: <p>I wrote simple function to trim spaces in text in function <code>trim</code>.
  It almost works. I have a problem because it should also change original string, but it doesn't. What is the problem? please describe. I appreciate any help. THANKS:)
  CODE:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string.h&gt;
  using namespace std;
  
  char* trim(char *str) {
  
      while(*str==' '){
          *str++;
      }
  
      char *newstr = str;
  
      return newstr; 
  }
  
  
  int main(){
      char str[] = "   Witaj cpp", *newstr;
  
      cout &lt;&lt; "start" &lt;&lt; str &lt;&lt; "end" &lt;&lt; endl;    // start   Witaj cppend
  
      newstr = trim(str);
  
      cout &lt;&lt; "start" &lt;&lt; str &lt;&lt; "end" &lt;&lt; endl;    // startWitaj cppend
  
      cout &lt;&lt; "start" &lt;&lt; newstr &lt;&lt; "end" &lt;&lt; endl;    // startWitaj cppend
  
      return 0;
  }
  </code></pre>