Hi...Plz i'm facing some problems on how to make my program work successfully.
i'm a beginner in the c++ and i have an assignement to make a text editor using the devc++..it requires certain functions and i've written this code so far but i can't handle except the choice number 2 and number 11..i've wriiten the functions i need in red colour..plz you can see the menu of functions i need in the source code and i need them to be solved using the fstream and strings...plz i'd really appreciate your concern:
#include <iostream>
#include <string>
#include <cctype>
#include <fstream>
using namespace std;
int main()
{
int choice;
int i=1;
string myFile ;
ifstream infile;
ofstream outfile;
cout << "Welcome To My Text Editor" <<endl;
cout << "Please Enter Your File's Name: ";
cin >> myFile;
outfile.open (myFile.c_str());
cout << "File " << myFile << " Doesn't Exist.I Created It For You" << endl;
outfile.close();
while (i>0)
{
cout << "\n\n" << "1. Add New Text To The End Of The File" << endl;
cout << "2. Display The Content Of The File" << endl;
cout << "3. Empty The File" << endl;
cout << "4. Encrypt The File Content" << endl;
cout << "5. Decrypt The File Content" << endl;
cout << "6. Merge Another File" << endl;
cout << "7. Count The Number Of Words In The File" << endl;
cout << "8. Search For A Word In The File" << endl;
cout << "9. Count The Number Of Times A Word Exists In The File" << endl;
cout << "10. Turn The File Content To Upper Case" << endl;
cout << "11. Exit" << endl;
cout << "\nPlease Enter Your Choice From The Menu Above: " ;
cin >> choice;
cout << "\n" ;
switch (choice)
{
case 2: {
infile.open (myFile.c_str(), ifstream::in);
while (infile.good())
cout << (char) infile.get();
infile.close();continue;
}
case 11: cout << "Thank You For Using My Text Editor" << endl; break;
default: cout << "Choice Not Available,Please Choose An Appropriate Choice"; continue;
}
system ("Pause");
return 0;
}
}