Let us see mkstemp system call example program to make temporary file. mkstemp() system call is used to create a temporary file under Linux/Unix operating system.

Let see below sample c code:

The program will create a temporary file inside /tmp named as FooXXXXXX. The XXXXXX will be replaced with some random string. With the write() system call we are writing hello and world to the newly created temp file FooXXXXXX.

Let us see the contents of the file:

mkstemp system call example program



Related Contents to follow