I have a text file to read. I would like to read from that file and store into a temporary file. I am not sure how to do this. How do I create a temporary file and do I use fprintf to store in that file?
You could use the function tmpfile() for that.
The tmpfile() function opens a unique temporary file in binary read/write (w+b) mode. The file will be automatically deleted when it is closed or the program terminates.
Example:
FILE * temp = tmpfile();
if(temp) {
fprintf(temp, "Hello, Temp!");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With