title: Reading a string and keep only the letters
body: <p>I want the user to enter a string, and then keep only the letters. My problem is  in the Function str in the second while loop it nevers copy the letter to the other string.It doesn't even print the j ! I really don't know why this is happening.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  void str(char *s)
  {
    int i=0,j=0;
    int sum=0;
  
    char *outstr;
    while(s[i]!='\0')
       {
         if(s[i]&gt;='a'&amp;&amp;s[i]&lt;='z'||s[i]&gt;='A'&amp;&amp;s[i]&lt;='Z')
          sum++;
        i++;
       }
     i=0;
     outstr=(char*)malloc(sum*sizeof(char));
     while(s[i]!='\0')
      {
        if(s[i]&gt;='a'&amp;&amp;s[i]&lt;='z'||s[i]&gt;='A'&amp;&amp;s[i]&lt;='Z')
           {
              strcpy(outstr[j],s[i]);
              j++;
              printf("\nj=%d",j);
           }
  
          printf("\ni=%d",i);
          i++;
  
      }
  
  
      printf("%s",outstr);
  }
  
  int main()
    {
       char s[650];
       int n;
       gets(s);
       str(s);
  
       return 0;
    }
  </code></pre>