title: Reading the number of characters in a string in C
body: <p>I want to use pipes to read a string in child process and send it to the parent, then count the number of characters in the string and display the number. The program runs only until I input a string. Can you please tell me what I'm doing wrong?</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include&lt;string.h&gt; 
  
  #define SIZE 1024
  
  
  int main()
  
  {
  
  int i,n,x;
  char msg[SIZE];  
  char str[SIZE]; 
  
  
  
  int p3[2];
  
  pipe(p3);
  
  int pid=fork();
  
  
  if(pid==0){
  
  
  close(p3[0]); //closing read end
  
  printf("Enter a string\n");
  fgets(msg,SIZE,stdin);
  
  write(p3[1],msg,sizeof(msg)); //writting into pipe
  close(p3[1]); //closing write end
  
  
  }
  
  else {
  
  close(p3[1]); //close write end
  
  read(p3[0], str, sizeof(str)); 
  
  int c = 0;
  
  while (str[c] != "Done")
     {
   for(i=0; i&lt;sizeof(str);i++){
        if (str[c] &gt;= 'a' &amp;&amp; str[c] &lt;= 'z') {
            c++;
  }
     }
  }
  
  printf("%d letters\n", c); 
  }
  
  return 0;
  }
  </code></pre>