You need to specify the append open mode like
#include <fstream> int main() { std::ofstream outfile; outfile.open("test.txt", std::ios_base::app); // append instead of overwrite outfile << "Data"; return 0; }
Related Posts:
- Why do we need virtual functions in C++?
- How do I fix a “Expected Primary-expression before ‘)’ token” error?
- What are the rules of the std::cin object in C++?
- C++ code file extension? What is the difference between .cc and .cpp
- C++ Error: ISO C++ Forbids Comparison Between Pointer and Integer [-fpermissive]
- segmentation fault 11 in C++ on Mac
- In C++, what is wx.h?
- Using “super” in C++
- new types may not be defined in a return type – C++
- declaring a priority_queue in c++ with a custom comparator
- C++ undefined reference to WinMain@16 (Code::Blocks)
- bit vectors in c++
- Very basic inheritance: error: expected class-name before ‘{’ token
- mkdir c++ function
- C++ Void Function with File Stream Error
- Error: “expected primary-expression before int”
- Operator Overloading C++; too many parameters for << operation
- How do I check if a Key is pressed on C++
- When is K 1024 and when is it 1000?
- Dial pad to get phone number (with Android button images)
- Why is it not possible to fake an IP address?
- Pause Console in C++ program
- Why the switch statement cannot be applied on strings?
- Authentication versus Authorization
- What is tail recursion?
- How to dynamically allocate arrays in C++
- How to convert string to char array in C++?
- How can I convert a std::string to int?
- What’s the C++ version of Java’s ArrayList
- what is svn? and how to use it with project?
- Incomplete Type Is Not Allowed
- When to use extern in C++
- how to implement quick sort algorithm in C++
- C++ Vector of pointers
- How do I reverse a C++ vector?
- C ++ error: a expected initializer before [function name]
- invalid new-expression of abstract class type
- std::string to char*
- Assembly’s manifest definition does not match assembly reference
- ‘do…while’ vs. ‘while’
- Does the ‘mutable’ keyword have any purpose other than allowing the variable to be modified by a const function?
- Visual Studio /**/ comment shortcut?
- “unrecognized selector sent to instance” error in Objective-C
- Random number c++ in some range
- What’s the equivalent of new/delete of C++ in C?
- How to use PHP’s password_hash to hash and verify passwords
- “g++” is not recognized as an internal or external command, MinGW
- Compiling a C++ program with gcc
- How to create a custom coder?
- What is the difference between const_iterator and non-const iterator in the C++ STL?
- Background color for Tk in Python
- how to uninstall MinGW and make cygwin ‘make’ as deafult make program with gcc 3.8.1
- Sorting Linked List C++ with pointers
- Get Unix timestamp with C++
- Class prototyping
- Cosine similarity and tf-idf
- 8 queens puzzle with user input c++
- How to dynamically allocate an array of pointers in C++?
- How do I compile C++ to JavaScript in a browser?
- Is the sizeof(some pointer) always equal to four?
- How do you initialise a dynamic array in C++?
- Excel Filters – show only relevant values in the filter
- Integer to hex string in C++
- Comparison of C++ unit test frameworks
- What is the difference between .cc and .cpp file suffix?
- C++ error: object of abstract class type is not allowed: pure virtual function has no overrider
- Unable to convert 3d ply file image to 2d image
- Correct way to work with vector of arrays
- What’s the difference between nexti and stepi in gdb?
- What is the difference between an Abstract Data Type(ADT) and a Data Structure?
- What does the term “empty loop” refer to exactly in C and C++?
- c++ error c2015: too many characters in constant
- Splitting a C++ std::string using tokens, e.g. “;”
- Py_Initialize fails – unable to load the file system codec
- Is it valid to have a html form inside another html form?
- C++ pass an array by reference
- How to print variable in sml?
- variable or field declared void
- Invalid conversion from ‘char’ to ‘const char *’
- How do I deal with “signed/unsigned mismatch” warnings (C4018)?
- Why is the minidlna database not being refreshed?
- Creating folders in C++
- java.sql.SQLException: Fail to convert to internal representation
- Representing EOF in C code?
- heap corruption detected | C++
- What’s the difference between sx and σx in the statistics calculations on a TI-Nspire?
- Update g++ but still old version
- module unsafe for SAFESEH image C++
- Why are there two different getline() functions (if indeed there are)?
- Apache Kafka vs Apache Storm
- Whats the difference between UInt8 and uint8_t
- database collation differences
- Add Woocommerce product to cart with Contact Form 7 [closed]
- To remove rendering of menus and header, plugin or theme?
- How long before an s3 bucket can be created with same name after deletion?
- Software vs hardware RAID performance and cache usage
- How do high traffic sites service more than 65535 TCP connections?
- Using variables in Apache config files to reduce duplication?
- How to unify package installation tasks in ansible?
- Private IP address in public DNS