Programming-Idioms

New implementation

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating resource.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
#include <stdlib.h>
const char tmpl[] = "XXXXXX.tmp";
int fd = mkstemp(tmpl);
(ns programming-idioms
  (:import [java.io File]))
(File/createTempFile "prefix" "suffix" (new File "/tmp"))
(ns programming-idioms
  (:import [java.io File]))
(File/createTempFile "prefix" "suffix")
using System.IO;
string file = Path.GetTempFileName();
import std.stdio;
auto f = File.tmpfile();
open (newunit=u,status="scratch")
import "io/ioutil"
tmpfile, err := ioutil.TempFile("", "")
import System.IO.Temp
withTempFile $ \f -> do
  -- do something with f
file = io.tmpfile()
$f = tmpfile();
sysutils
var
  H: THandle;
begin
  H := FileCreate(GetTempFileName);
end.
use Path::Tiny qw(tempfile);
my $path = tempfile;
import tempfile
file = tempfile.TemporaryFile()
require 'tempfile'
file = Tempfile.new('foo') 
use tempdir::TempDir;
use std::fs::File;
let temp_dir = TempDir::new("prefix")?;
let temp_file = File::open(temp_dir.path().join("file_name"))?;