WeixiangYan/CodeTransOcean huggingface dataset:
Task: Almost prime

C: #include <stdio.h>

int kprime(int n, int k)
{
	int p, f = 0;
	for (p = 2; f < k && p*p <= n; p++)
		while (0 == n % p)
			n /= p, f++;

	return f + (n > 1) == k;
}

int main(void)
{
	int i, c, k;

	for (k = 1; k <= 5; k++) {
		printf("k = %d:", k);

		for (i = 2, c = 0; c < 10; i++)
			if (kprime(i, k)) {
				printf(" %d", i);
				c++;
			}

		putchar('\n');
	}

	return 0;
}




Go: package main

import "fmt"

func kPrime(n, k int) bool {
    nf := 0
    for i := 2; i <= n; i++ {
        for n%i == 0 {
            if nf == k {
                return false
            }
            nf++
            n /= i
        }
    }
    return nf == k
}

func gen(k, n int) []int {
    r := make([]int, n)
    n = 2
    for i := range r {
        for !kPrime(n, k) {
            n++
        }
        r[i] = n
        n++
    }
    return r
}

func main() {
    for k := 1; k <= 5; k++ {
        fmt.Println(k, gen(k, 10))
    }
}
Task: Almost prime

C: #include <stdio.h>

int kprime(int n, int k)
{
	int p, f = 0;
	for (p = 2; f < k && p*p <= n; p++)
		while (0 == n % p)
			n /= p, f++;

	return f + (n > 1) == k;
}

int main(void)
{
	int i, c, k;

	for (k = 1; k <= 5; k++) {
		printf("k = %d:", k);

		for (i = 2, c = 0; c < 10; i++)
			if (kprime(i, k)) {
				printf(" %d", i);
				c++;
			}

		putchar('\n');
	}

	return 0;
}





Java: public class AlmostPrime {
    public static void main(String[] args) {
        for (int k = 1; k <= 5; k++) {
            System.out.print("k = " + k + ":");

            for (int i = 2, c = 0; c < 10; i++) {
                if (kprime(i, k)) {
                    System.out.print(" " + i);
                    c++;
                }
            }

            System.out.println("");
        }
    }

    public static boolean kprime(int n, int k) {
        int f = 0;
        for (int p = 2; f < k && p * p <= n; p++) {
            while (n % p == 0) {
                n /= p;
                f++;
            }
        }
        return f + ((n > 1) ? 1 : 0) == k;
    }
}
Task: Almost prime

C: #include <stdio.h>

int kprime(int n, int k)
{
	int p, f = 0;
	for (p = 2; f < k && p*p <= n; p++)
		while (0 == n % p)
			n /= p, f++;

	return f + (n > 1) == k;
}

int main(void)
{
	int i, c, k;

	for (k = 1; k <= 5; k++) {
		printf("k = %d:", k);

		for (i = 2, c = 0; c < 10; i++)
			if (kprime(i, k)) {
				printf(" %d", i);
				c++;
			}

		putchar('\n');
	}

	return 0;
}







Python: from prime_decomposition import decompose
from itertools import islice, count
try: 
    from functools import reduce
except: 
    pass


def almostprime(n, k=2):
    d = decompose(n)
    try:
        terms = [next(d) for i in range(k)]
        return reduce(int.__mul__, terms, 1) == n
    except:
        return False

if __name__ == '__main__':
    for k in range(1,6):
        print('%i: %r' % (k, list(islice((n for n in count() if almostprime(n, k)), 10))))
Task: Almost prime

C: #include <stdio.h>

int kprime(int n, int k)
{
	int p, f = 0;
	for (p = 2; f < k && p*p <= n; p++)
		while (0 == n % p)
			n /= p, f++;

	return f + (n > 1) == k;
}

int main(void)
{
	int i, c, k;

	for (k = 1; k <= 5; k++) {
		printf("k = %d:", k);

		for (i = 2, c = 0; c < 10; i++)
			if (kprime(i, k)) {
				printf(" %d", i);
				c++;
			}

		putchar('\n');
	}

	return 0;
}








VB: Private Function kprime(ByVal n As Integer, k As Integer) As Boolean
    Dim p As Integer, factors As Integer
    p = 2
    factors = 0
    Do While factors < k And p * p <= n
        Do While n Mod p = 0
            n = n / p
            factors = factors + 1
        Loop
        p = p + 1
    Loop
    factors = factors - (n > 1) 
    kprime = factors = k
End Function
 
Private Sub almost_primeC()
    Dim nextkprime As Integer, count As Integer
    Dim k As Integer
    For k = 1 To 5
        Debug.Print "k ="; k; ":";
        nextkprime = 2
        count = 0
        Do While count < 10
            If kprime(nextkprime, k) Then
                Debug.Print " "; Format(CStr(nextkprime), "@@@@@");
                count = count + 1
            End If
            nextkprime = nextkprime + 1
        Loop
        Debug.Print
    Next k
End Sub
Task: Almost prime


C++: #include <cstdlib>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <list>

bool k_prime(unsigned n, unsigned k) {
    unsigned f = 0;
    for (unsigned p = 2; f < k && p * p <= n; p++)
        while (0 == n % p) { n /= p; f++; }
    return f + (n > 1 ? 1 : 0) == k;
}

std::list<unsigned> primes(unsigned k, unsigned n)  {
    std::list<unsigned> list;
    for (unsigned i = 2;list.size() < n;i++)
        if (k_prime(i, k)) list.push_back(i);
    return list;
}

int main(const int argc, const char* argv[]) {
    using namespace std;
    for (unsigned k = 1; k <= 5; k++) {
        ostringstream os("");
        const list<unsigned> l = primes(k, 10);
        for (list<unsigned>::const_iterator i = l.begin(); i != l.end(); i++)
            os << setw(4) << *i;
        cout << "k = " << k << ':' << os.str() << endl;
    }

	return EXIT_SUCCESS;
}



Go: package main

import "fmt"

func kPrime(n, k int) bool {
    nf := 0
    for i := 2; i <= n; i++ {
        for n%i == 0 {
            if nf == k {
                return false
            }
            nf++
            n /= i
        }
    }
    return nf == k
}

func gen(k, n int) []int {
    r := make([]int, n)
    n = 2
    for i := range r {
        for !kPrime(n, k) {
            n++
        }
        r[i] = n
        n++
    }
    return r
}

func main() {
    for k := 1; k <= 5; k++ {
        fmt.Println(k, gen(k, 10))
    }
}
Task: Almost prime


C++: #include <cstdlib>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <list>

bool k_prime(unsigned n, unsigned k) {
    unsigned f = 0;
    for (unsigned p = 2; f < k && p * p <= n; p++)
        while (0 == n % p) { n /= p; f++; }
    return f + (n > 1 ? 1 : 0) == k;
}

std::list<unsigned> primes(unsigned k, unsigned n)  {
    std::list<unsigned> list;
    for (unsigned i = 2;list.size() < n;i++)
        if (k_prime(i, k)) list.push_back(i);
    return list;
}

int main(const int argc, const char* argv[]) {
    using namespace std;
    for (unsigned k = 1; k <= 5; k++) {
        ostringstream os("");
        const list<unsigned> l = primes(k, 10);
        for (list<unsigned>::const_iterator i = l.begin(); i != l.end(); i++)
            os << setw(4) << *i;
        cout << "k = " << k << ':' << os.str() << endl;
    }

	return EXIT_SUCCESS;
}




Java: public class AlmostPrime {
    public static void main(String[] args) {
        for (int k = 1; k <= 5; k++) {
            System.out.print("k = " + k + ":");

            for (int i = 2, c = 0; c < 10; i++) {
                if (kprime(i, k)) {
                    System.out.print(" " + i);
                    c++;
                }
            }

            System.out.println("");
        }
    }

    public static boolean kprime(int n, int k) {
        int f = 0;
        for (int p = 2; f < k && p * p <= n; p++) {
            while (n % p == 0) {
                n /= p;
                f++;
            }
        }
        return f + ((n > 1) ? 1 : 0) == k;
    }
}
Task: Almost prime


C++: #include <cstdlib>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <list>

bool k_prime(unsigned n, unsigned k) {
    unsigned f = 0;
    for (unsigned p = 2; f < k && p * p <= n; p++)
        while (0 == n % p) { n /= p; f++; }
    return f + (n > 1 ? 1 : 0) == k;
}

std::list<unsigned> primes(unsigned k, unsigned n)  {
    std::list<unsigned> list;
    for (unsigned i = 2;list.size() < n;i++)
        if (k_prime(i, k)) list.push_back(i);
    return list;
}

int main(const int argc, const char* argv[]) {
    using namespace std;
    for (unsigned k = 1; k <= 5; k++) {
        ostringstream os("");
        const list<unsigned> l = primes(k, 10);
        for (list<unsigned>::const_iterator i = l.begin(); i != l.end(); i++)
            os << setw(4) << *i;
        cout << "k = " << k << ':' << os.str() << endl;
    }

	return EXIT_SUCCESS;
}






Python: from prime_decomposition import decompose
from itertools import islice, count
try: 
    from functools import reduce
except: 
    pass


def almostprime(n, k=2):
    d = decompose(n)
    try:
        terms = [next(d) for i in range(k)]
        return reduce(int.__mul__, terms, 1) == n
    except:
        return False

if __name__ == '__main__':
    for k in range(1,6):
        print('%i: %r' % (k, list(islice((n for n in count() if almostprime(n, k)), 10))))
Task: Almost prime





Java: public class AlmostPrime {
    public static void main(String[] args) {
        for (int k = 1; k <= 5; k++) {
            System.out.print("k = " + k + ":");

            for (int i = 2, c = 0; c < 10; i++) {
                if (kprime(i, k)) {
                    System.out.print(" " + i);
                    c++;
                }
            }

            System.out.println("");
        }
    }

    public static boolean kprime(int n, int k) {
        int f = 0;
        for (int p = 2; f < k && p * p <= n; p++) {
            while (n % p == 0) {
                n /= p;
                f++;
            }
        }
        return f + ((n > 1) ? 1 : 0) == k;
    }
}




VB: Private Function kprime(ByVal n As Integer, k As Integer) As Boolean
    Dim p As Integer, factors As Integer
    p = 2
    factors = 0
    Do While factors < k And p * p <= n
        Do While n Mod p = 0
            n = n / p
            factors = factors + 1
        Loop
        p = p + 1
    Loop
    factors = factors - (n > 1) 
    kprime = factors = k
End Function
 
Private Sub almost_primeC()
    Dim nextkprime As Integer, count As Integer
    Dim k As Integer
    For k = 1 To 5
        Debug.Print "k ="; k; ":";
        nextkprime = 2
        count = 0
        Do While count < 10
            If kprime(nextkprime, k) Then
                Debug.Print " "; Format(CStr(nextkprime), "@@@@@");
                count = count + 1
            End If
            nextkprime = nextkprime + 1
        Loop
        Debug.Print
    Next k
End Sub
Task: Almost prime




Go: package main

import "fmt"

func kPrime(n, k int) bool {
    nf := 0
    for i := 2; i <= n; i++ {
        for n%i == 0 {
            if nf == k {
                return false
            }
            nf++
            n /= i
        }
    }
    return nf == k
}

func gen(k, n int) []int {
    r := make([]int, n)
    n = 2
    for i := range r {
        for !kPrime(n, k) {
            n++
        }
        r[i] = n
        n++
    }
    return r
}

func main() {
    for k := 1; k <= 5; k++ {
        fmt.Println(k, gen(k, 10))
    }
}




Python: from prime_decomposition import decompose
from itertools import islice, count
try: 
    from functools import reduce
except: 
    pass


def almostprime(n, k=2):
    d = decompose(n)
    try:
        terms = [next(d) for i in range(k)]
        return reduce(int.__mul__, terms, 1) == n
    except:
        return False

if __name__ == '__main__':
    for k in range(1,6):
        print('%i: %r' % (k, list(islice((n for n in count() if almostprime(n, k)), 10))))
Task: Almost prime







Python: from prime_decomposition import decompose
from itertools import islice, count
try: 
    from functools import reduce
except: 
    pass


def almostprime(n, k=2):
    d = decompose(n)
    try:
        terms = [next(d) for i in range(k)]
        return reduce(int.__mul__, terms, 1) == n
    except:
        return False

if __name__ == '__main__':
    for k in range(1,6):
        print('%i: %r' % (k, list(islice((n for n in count() if almostprime(n, k)), 10))))


VB: Private Function kprime(ByVal n As Integer, k As Integer) As Boolean
    Dim p As Integer, factors As Integer
    p = 2
    factors = 0
    Do While factors < k And p * p <= n
        Do While n Mod p = 0
            n = n / p
            factors = factors + 1
        Loop
        p = p + 1
    Loop
    factors = factors - (n > 1) 
    kprime = factors = k
End Function
 
Private Sub almost_primeC()
    Dim nextkprime As Integer, count As Integer
    Dim k As Integer
    For k = 1 To 5
        Debug.Print "k ="; k; ":";
        nextkprime = 2
        count = 0
        Do While count < 10
            If kprime(nextkprime, k) Then
                Debug.Print " "; Format(CStr(nextkprime), "@@@@@");
                count = count + 1
            End If
            nextkprime = nextkprime + 1
        Loop
        Debug.Print
    Next k
End Sub
Task: Almost prime


C++: #include <cstdlib>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <list>

bool k_prime(unsigned n, unsigned k) {
    unsigned f = 0;
    for (unsigned p = 2; f < k && p * p <= n; p++)
        while (0 == n % p) { n /= p; f++; }
    return f + (n > 1 ? 1 : 0) == k;
}

std::list<unsigned> primes(unsigned k, unsigned n)  {
    std::list<unsigned> list;
    for (unsigned i = 2;list.size() < n;i++)
        if (k_prime(i, k)) list.push_back(i);
    return list;
}

int main(const int argc, const char* argv[]) {
    using namespace std;
    for (unsigned k = 1; k <= 5; k++) {
        ostringstream os("");
        const list<unsigned> l = primes(k, 10);
        for (list<unsigned>::const_iterator i = l.begin(); i != l.end(); i++)
            os << setw(4) << *i;
        cout << "k = " << k << ':' << os.str() << endl;
    }

	return EXIT_SUCCESS;
}







VB: Private Function kprime(ByVal n As Integer, k As Integer) As Boolean
    Dim p As Integer, factors As Integer
    p = 2
    factors = 0
    Do While factors < k And p * p <= n
        Do While n Mod p = 0
            n = n / p
            factors = factors + 1
        Loop
        p = p + 1
    Loop
    factors = factors - (n > 1) 
    kprime = factors = k
End Function
 
Private Sub almost_primeC()
    Dim nextkprime As Integer, count As Integer
    Dim k As Integer
    For k = 1 To 5
        Debug.Print "k ="; k; ":";
        nextkprime = 2
        count = 0
        Do While count < 10
            If kprime(nextkprime, k) Then
                Debug.Print " "; Format(CStr(nextkprime), "@@@@@");
                count = count + 1
            End If
            nextkprime = nextkprime + 1
        Loop
        Debug.Print
    Next k
End Sub
Task: Almost prime




Go: package main

import "fmt"

func kPrime(n, k int) bool {
    nf := 0
    for i := 2; i <= n; i++ {
        for n%i == 0 {
            if nf == k {
                return false
            }
            nf++
            n /= i
        }
    }
    return nf == k
}

func gen(k, n int) []int {
    r := make([]int, n)
    n = 2
    for i := range r {
        for !kPrime(n, k) {
            n++
        }
        r[i] = n
        n++
    }
    return r
}

func main() {
    for k := 1; k <= 5; k++ {
        fmt.Println(k, gen(k, 10))
    }
}


Java: public class AlmostPrime {
    public static void main(String[] args) {
        for (int k = 1; k <= 5; k++) {
            System.out.print("k = " + k + ":");

            for (int i = 2, c = 0; c < 10; i++) {
                if (kprime(i, k)) {
                    System.out.print(" " + i);
                    c++;
                }
            }

            System.out.println("");
        }
    }

    public static boolean kprime(int n, int k) {
        int f = 0;
        for (int p = 2; f < k && p * p <= n; p++) {
            while (n % p == 0) {
                n /= p;
                f++;
            }
        }
        return f + ((n > 1) ? 1 : 0) == k;
    }
}
Task: Almost prime




Go: package main

import "fmt"

func kPrime(n, k int) bool {
    nf := 0
    for i := 2; i <= n; i++ {
        for n%i == 0 {
            if nf == k {
                return false
            }
            nf++
            n /= i
        }
    }
    return nf == k
}

func gen(k, n int) []int {
    r := make([]int, n)
    n = 2
    for i := range r {
        for !kPrime(n, k) {
            n++
        }
        r[i] = n
        n++
    }
    return r
}

func main() {
    for k := 1; k <= 5; k++ {
        fmt.Println(k, gen(k, 10))
    }
}





VB: Private Function kprime(ByVal n As Integer, k As Integer) As Boolean
    Dim p As Integer, factors As Integer
    p = 2
    factors = 0
    Do While factors < k And p * p <= n
        Do While n Mod p = 0
            n = n / p
            factors = factors + 1
        Loop
        p = p + 1
    Loop
    factors = factors - (n > 1) 
    kprime = factors = k
End Function
 
Private Sub almost_primeC()
    Dim nextkprime As Integer, count As Integer
    Dim k As Integer
    For k = 1 To 5
        Debug.Print "k ="; k; ":";
        nextkprime = 2
        count = 0
        Do While count < 10
            If kprime(nextkprime, k) Then
                Debug.Print " "; Format(CStr(nextkprime), "@@@@@");
                count = count + 1
            End If
            nextkprime = nextkprime + 1
        Loop
        Debug.Print
    Next k
End Sub
Task: Almost prime





Java: public class AlmostPrime {
    public static void main(String[] args) {
        for (int k = 1; k <= 5; k++) {
            System.out.print("k = " + k + ":");

            for (int i = 2, c = 0; c < 10; i++) {
                if (kprime(i, k)) {
                    System.out.print(" " + i);
                    c++;
                }
            }

            System.out.println("");
        }
    }

    public static boolean kprime(int n, int k) {
        int f = 0;
        for (int p = 2; f < k && p * p <= n; p++) {
            while (n % p == 0) {
                n /= p;
                f++;
            }
        }
        return f + ((n > 1) ? 1 : 0) == k;
    }
}



Python: from prime_decomposition import decompose
from itertools import islice, count
try: 
    from functools import reduce
except: 
    pass


def almostprime(n, k=2):
    d = decompose(n)
    try:
        terms = [next(d) for i in range(k)]
        return reduce(int.__mul__, terms, 1) == n
    except:
        return False

if __name__ == '__main__':
    for k in range(1,6):
        print('%i: %r' % (k, list(islice((n for n in count() if almostprime(n, k)), 10))))
Task: Secure temporary file

C: #include <stdlib.h>
#include <stdio.h>

int main(void)
{
  FILE *fh = tmpfile(); 
  
  fclose(fh);
  
  return 0;
}



C#: using System;
using System.IO;

Console.WriteLine(Path.GetTempFileName());
Task: Secure temporary file

C: #include <stdlib.h>
#include <stdio.h>

int main(void)
{
  FILE *fh = tmpfile(); 
  
  fclose(fh);
  
  return 0;
}




Go: package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"os"
)

func main() {
	f, err := ioutil.TempFile("", "foo")
	if err != nil {
		log.Fatal(err)
	}
	defer f.Close()

	
	
	defer os.Remove(f.Name())

	
	fmt.Fprintln(f, "Using temporary file:", f.Name())
	f.Seek(0, 0)
	d, err := ioutil.ReadAll(f)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("Wrote and read: %s\n", d)

        
        
}
Task: Secure temporary file

C: #include <stdlib.h>
#include <stdio.h>

int main(void)
{
  FILE *fh = tmpfile(); 
  
  fclose(fh);
  
  return 0;
}





Java: import java.io.File;
import java.io.IOException;

public class CreateTempFile {
    public static void main(String[] args)  {
        try {
            
            File temp = File.createTempFile("temp-file-name", ".tmp");
            System.out.println("Temp file : " + temp.getAbsolutePath());
        }
        catch(IOException e) {
            e.printStackTrace();
    	}
    }
}
Task: Secure temporary file

C: #include <stdlib.h>
#include <stdio.h>

int main(void)
{
  FILE *fh = tmpfile(); 
  
  fclose(fh);
  
  return 0;
}







Python: >>> import tempfile
>>> invisible = tempfile.TemporaryFile()
>>> invisible.name
'<fdopen>'
>>> visible = tempfile.NamedTemporaryFile()
>>> visible.name
'/tmp/tmpZNfc_s'
>>> visible.close()
>>> invisible.close()
Task: Secure temporary file



C#: using System;
using System.IO;

Console.WriteLine(Path.GetTempFileName());


Go: package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"os"
)

func main() {
	f, err := ioutil.TempFile("", "foo")
	if err != nil {
		log.Fatal(err)
	}
	defer f.Close()

	
	
	defer os.Remove(f.Name())

	
	fmt.Fprintln(f, "Using temporary file:", f.Name())
	f.Seek(0, 0)
	d, err := ioutil.ReadAll(f)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("Wrote and read: %s\n", d)

        
        
}
Task: Secure temporary file



C#: using System;
using System.IO;

Console.WriteLine(Path.GetTempFileName());



Java: import java.io.File;
import java.io.IOException;

public class CreateTempFile {
    public static void main(String[] args)  {
        try {
            
            File temp = File.createTempFile("temp-file-name", ".tmp");
            System.out.println("Temp file : " + temp.getAbsolutePath());
        }
        catch(IOException e) {
            e.printStackTrace();
    	}
    }
}
Task: Secure temporary file



C#: using System;
using System.IO;

Console.WriteLine(Path.GetTempFileName());





Python: >>> import tempfile
>>> invisible = tempfile.TemporaryFile()
>>> invisible.name
'<fdopen>'
>>> visible = tempfile.NamedTemporaryFile()
>>> visible.name
'/tmp/tmpZNfc_s'
>>> visible.close()
>>> invisible.close()
Task: Secure temporary file




Go: package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"os"
)

func main() {
	f, err := ioutil.TempFile("", "foo")
	if err != nil {
		log.Fatal(err)
	}
	defer f.Close()

	
	
	defer os.Remove(f.Name())

	
	fmt.Fprintln(f, "Using temporary file:", f.Name())
	f.Seek(0, 0)
	d, err := ioutil.ReadAll(f)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("Wrote and read: %s\n", d)

        
        
}


Java: import java.io.File;
import java.io.IOException;

public class CreateTempFile {
    public static void main(String[] args)  {
        try {
            
            File temp = File.createTempFile("temp-file-name", ".tmp");
            System.out.println("Temp file : " + temp.getAbsolutePath());
        }
        catch(IOException e) {
            e.printStackTrace();
    	}
    }
}
Task: Secure temporary file




Go: package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"os"
)

func main() {
	f, err := ioutil.TempFile("", "foo")
	if err != nil {
		log.Fatal(err)
	}
	defer f.Close()

	
	
	defer os.Remove(f.Name())

	
	fmt.Fprintln(f, "Using temporary file:", f.Name())
	f.Seek(0, 0)
	d, err := ioutil.ReadAll(f)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("Wrote and read: %s\n", d)

        
        
}




Python: >>> import tempfile
>>> invisible = tempfile.TemporaryFile()
>>> invisible.name
'<fdopen>'
>>> visible = tempfile.NamedTemporaryFile()
>>> visible.name
'/tmp/tmpZNfc_s'
>>> visible.close()
>>> invisible.close()
Task: Secure temporary file





Java: import java.io.File;
import java.io.IOException;

public class CreateTempFile {
    public static void main(String[] args)  {
        try {
            
            File temp = File.createTempFile("temp-file-name", ".tmp");
            System.out.println("Temp file : " + temp.getAbsolutePath());
        }
        catch(IOException e) {
            e.printStackTrace();
    	}
    }
}



Python: >>> import tempfile
>>> invisible = tempfile.TemporaryFile()
>>> invisible.name
'<fdopen>'
>>> visible = tempfile.NamedTemporaryFile()
>>> visible.name
'/tmp/tmpZNfc_s'
>>> visible.close()
>>> invisible.close()
Task: Secure temporary file

C: #include <stdlib.h>
#include <stdio.h>

int main(void)
{
  FILE *fh = tmpfile(); 
  
  fclose(fh);
  
  return 0;
}






PHP: $fh = tmpfile();

fclose($fh);


$filename = tempnam('/tmp', 'prefix');
echo "$filename\n";
Task: Secure temporary file



C#: using System;
using System.IO;

Console.WriteLine(Path.GetTempFileName());




PHP: $fh = tmpfile();

fclose($fh);


$filename = tempnam('/tmp', 'prefix');
echo "$filename\n";
Task: Secure temporary file




Go: package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"os"
)

func main() {
	f, err := ioutil.TempFile("", "foo")
	if err != nil {
		log.Fatal(err)
	}
	defer f.Close()

	
	
	defer os.Remove(f.Name())

	
	fmt.Fprintln(f, "Using temporary file:", f.Name())
	f.Seek(0, 0)
	d, err := ioutil.ReadAll(f)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("Wrote and read: %s\n", d)

        
        
}



PHP: $fh = tmpfile();

fclose($fh);


$filename = tempnam('/tmp', 'prefix');
echo "$filename\n";