title: Writing String.trim() in C
body: <blockquote>
  <p><strong>Possible Duplicates:</strong><br />
  <a href="https://stackoverflow.com/questions/122616/painless-way-to-trim-leading-trailing-whitespace-in-c">Painless way to trim leading/trailing whitespace in C?</a><br />
  <a href="https://stackoverflow.com/questions/656542/trim-a-string-in-c">Trim a string in C</a></p>
  </blockquote>
  
  <p>I was writing the String trim method in c and this is the code I came up with. I think it does the job of eliminating leading and trailing whitespaces however, I wish the code could be cleaner. Can you suggest improvements?</p>
  <pre><code>void trim(char *String)
  {
  int i=0;j=0;
  char c,lastc;
  while(String[i])
  {
     c=String[i];
     if(c!=' ')
     {
       String[j]=c;
       j++;
     }
     else if(lastc!= ' ')
     {
       String[j]=c;
       j++;
  
     }
     lastc = c;
     i++;
  }
  </code></pre>
  <p>Does this code look clean ??</p>