title: programming in C with an input buffer
body: <p>I am currently working on an assignment for my C programming class and one of the problems wants me to create a method to get input from the keyboard with a buffer sized to hold 5 characters. It then says that the string entered should be 18 characters. Im a little confused as to what he means by this. Ill post the entire assignment down below.</p>
  
  <p>Write the functions</p>
  
  <pre><code>char *stripCR(char *s);
  </code></pre>
  
  <p>which replaces the newline character, if any, at the end of the string pointed to by s, and</p>
  
  <pre><code>int checkCR(char *s);
  </code></pre>
  
  <p>which returns a true (1) if the string pointed to by s ends with a newline character.</p>
  
  <p>Write a test program that uses 
      fgets() </p>
  
  <p>to get input from the keyboard into a buffer. The buffer should be
  sized to hold 5 characters and the string that is entered should be about 18 characters long. The
  program should indicate whether the string has the newline character, print out the string as returned
  by fgets() surrounded by square brackets (so that the presence of a newline is obvious) and then strip
  the newline character and print the string again (surrounding by square brackets). It should continue to
  do this in a loop until it detects that the string returned by fgets() ends with a newline character. </p>