pointer.pass.cpp revision 13aaf422e49fa4b66642966bfc6078b5d9adde12
1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <fstream>
11
12// template <class charT, class traits = char_traits<charT> >
13// class basic_ofstream
14
15// explicit basic_ofstream(const char* s, ios_base::openmode mode = ios_base::out);
16
17#include <fstream>
18#include <cassert>
19
20int main()
21{
22    char temp[L_tmpnam];
23    tmpnam(temp);
24    {
25        std::ofstream fs(temp);
26        fs << 3.25;
27    }
28    {
29        std::ifstream fs(temp);
30        double x = 0;
31        fs >> x;
32        assert(x == 3.25);
33    }
34    remove(temp);
35    {
36        std::wofstream fs(temp);
37        fs << 3.25;
38    }
39    {
40        std::wifstream fs(temp);
41        double x = 0;
42        fs >> x;
43        assert(x == 3.25);
44    }
45    remove(temp);
46}
47