Search code examples
cfileiostdin

Reading from stdin into a FILE*


I have a functions that expects a FILE* and I usually create that by reading from a file. Now under certain circumstances I want to read from stdin. Is there a way to read a sentence with previously unspecified length from stdin and write it into a FILE* ?


Solution

  • stdin, stdout and stderr are already of type FILE *. So you can use it like any other FILE * variable.