pointer.pass.cpp revision 06d8bf6ce2008526732ae40ad46f7ff031c409e7
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#include "platform_support.h" 20 21int main() 22{ 23 std::string temp = get_temp_file_name(); 24 { 25 std::ofstream fs(temp.c_str()); 26 fs << 3.25; 27 } 28 { 29 std::ifstream fs(temp.c_str()); 30 double x = 0; 31 fs >> x; 32 assert(x == 3.25); 33 } 34 std::remove(temp.c_str()); 35 { 36 std::wofstream fs(temp.c_str()); 37 fs << 3.25; 38 } 39 { 40 std::wifstream fs(temp.c_str()); 41 double x = 0; 42 fs >> x; 43 assert(x == 3.25); 44 } 45 std::remove(temp.c_str()); 46} 47