fgets is better than gets because it specifies a maximum count and won't overflow the buffer. Use stdin for the file pointer. If the string ends with \n then that is all the user entered; if not, there is more and another call to fgets will pick up the next lot of characters.