#include <stdio.h>

char *mygettext(char *text, size_t size)
{
   size_t i = 0;
   for ( ;; )
   {
      int ch = fgetc(stdin);
      if ( ch == '\n' || ch == EOF )
      {
         break;
      }
      if ( i < size - 1 )
      {
         text[i++] = ch;
      }
   }
   text[i] = '\0';
   return text;
}

int main(void)
{
   int i;
   for ( i = 0; i < 3; ++i )
   {
      char text[20];
      fputs("prompt: ", stdout);
      fflush(stdout);
      printf("text = \"%s\"\n", mygettext(text, sizeof text));
   }
   return 0;
}

/* my input/output
prompt: 1234567890123456789012345
text = "1234567890123456789"
prompt: hello world
text = "hello world"
prompt: goodbye
text = "goodbye"
*/
The article starter has earned a lot of community kudos, and such articles offer a bounty for quality replies.