Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am trying to read a list of words from a file example.txt and sort the list and rewrite the sorted list to the file.

I am trying to read a list of words from a file example.txt and sort the list and rewrite the sorted list to the file. So far I am able to read and sort the list but am unable to rewrite the sorted list to the file. Also the last entry is read twice how do I avoid this? C++

image text in transcribed

image text in transcribed

1 #include 2 #include 3 #include 4 #include 5 #include 7 using namespace std; 9 int main() I/create fstream instance and open file "example.txt" 2 fstream sf 3 sf.open("example.txt", fstream::out 2 fstream::in); 5 if(sf.is_open )) cout word; //cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application And Administration

Authors: Michael Mannino, Michael V. Mannino

2nd Edition

0072880678, 9780072880670

More Books

Students also viewed these Databases questions