i know that its so easy. but i dont know how to do it. ive tried ifstream and ofstream to add a line in a text file. and im sure someone in the past may have already posted this kind of problem. can anyone give me a link to that thread? thanks.
jogieglenmait 0
Light Poster
Recommended Answers
Jump to Poststd::stringstream ss; ss << "A line of text." std::ofstream file("lines.txt", std::ios::out | std::ios::app); if(file.is_open()) file << ss.str() << '\n'; file.close();
Edit: Couple notes
You may want to read about ofstream flags, they are non-trivial.
Closing the file is important.
You don't need to use a stringstream like …
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.