You’re specifying std::fstream::in
in your call to fstream::open(). This is known to force it to require an existing file.
Either remove std::fstream::in
from your mode
argument, or specify std::fstream::trunc
in addition to the other flags.
More Related Contents:
- How to read a growing text file in C++?
- In which scenario do I use a particular STL container?
- C++ sorting and keeping track of indexes
- What are the complexity guarantees of the standard containers?
- Remove spaces from std::string in C++
- How do I sort a std::vector by the values of a different std::vector?
- Why should one not derive from c++ std string class?
- problem sorting using member function as comparator
- Why can’t simple initialize (with braces) 2D std::array? [duplicate]
- Why can’t we declare a std::vector?
- Efficient way of reading a file into an std::vector?
- Determine if a type is an STL container at compile time
- How to initialize std::vector from C-style array?
- Sorting a vector in descending order
- C++ Double Address Operator? (&&)
- Why is it OK to return a ‘vector’ from a function?
- vector::at vs. vector::operator[]
- c++ exception : throwing std::string
- How can currying be done in C++?
- Why don’t the std::fstream classes take a std::string?
- how portable is end iterator decrement?
- Sorting a std::vector by the string?
- Template class with template container
- Windows Unicode C++ Stream Output Failure
- Can raw pointers be used instead of iterators with STL algorithms for containers with linear storage?
- STL remove doesn’t work as expected?
- std::back_inserter for a std::set?
- Converting between C++ std::vector and C array without copying
- C++, can I statically initialize a std::map at compile time?
- std::ofstream, check if file exists before writing