0

I'd like to create a temporary file stream. Is there a c++ equivalent to C's tmpfile() function.

If not, how would I create one?

P3trus
  • 6,747
  • 8
  • 40
  • 54
  • What platform ? If on unix, this is a duplicate of http://stackoverflow.com/questions/499636/c-how-to-create-a-stdofstream-to-a-temp-file . – Alexandre C. Apr 07 '11 at 15:42

2 Answers2

3

You may want to see this.

Community
  • 1
  • 1
Donotalo
  • 12,748
  • 25
  • 83
  • 121
0

You could check whether your implementation offers a std::fstream constructor that takes a file descriptor, and if so use fileno to get the fd from the FILE* returned by tmpfile(). But the C++ standard doesn't guarantee that constructor.

Steve Jessop
  • 273,490
  • 39
  • 460
  • 699