title: How to read newline character('\n') delimited strings until EOF in C?
body: <p>For example, I am writing a C function that replace a substring <code>s1</code> in string <code>source</code> with a new string <code>s2</code>. But I am having trouble with reading the input from stdin. I also want it to end until an <code>EOF</code> is met.</p>
  
  <p>I search a lot about "read until EOF" and "read a string containing whitespace", but I didnt make it to work.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  {
    char source[120], s1[20], s2[20];
    ...
    //what ever to input multiple cases of source, s1, and s2 until EOF is met
    replace(source, s1, s2);
    printf("%s\n",source); 
  
    return 0;
  }
  </code></pre>