This is due tomorrow, Please help.

Pages: 12
oh shoot, that works perfectly fine aswell.
Just got finished working on the code and everything works perfectly just as it should. Thanks for all the help dasani885 , you helped me throughout the whole way and i really appreciate it. Here is all the code in all of its glory.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <iostream>
#include <fstream>
#include <string>
#include <stdio.h>

using namespace std;

int main()
{
    char choice;
    string filename, text;
    ofstream f;
    ifstream infile;
    do{
            int option;
    cout << "***Menu***" << endl;
    cout << "1.Create a File" << endl;
    cout << "2.Display a File" << endl;
    cout << "3.Edit a File" << endl;
    cout << "4.Delete a File" << endl;
    cin >> option;

      switch (option)
   {
      case 1:
      cout << "What would you like to name your file?" << endl;
      cin >> filename;
      f.open ( filename.c_str() );
      f.close();
      cout << "Successfully created: " << filename << endl;
      break;
      case 2:
      cout << "What is the name of the file you would like to display?" << endl;
      cin >> filename;
     infile.open(filename.c_str());
     if(!infile)
     {
         cout << "Unable to open file\n";
     }
     else
     {
          cout << "Reading file: " << filename << endl;
         while (getline(infile,filename)){
          cout << "This file says: " << filename << endl;
          f.close();
         }
     }
      break;
      case 3:
      cout << "What is the name of the file you would like to edit?" << endl;
      cin >> filename;
      f.open(filename.c_str(),ios::out | ios::in);
      if (!infile)
      {
          cout << "unable to open file\n";
      }
      else
      {
          cout << "Found File...Opening..." << endl;
          cout << "What would you like to write into this file?" << endl;
          cin.ignore();
          getline (cin,text);
          f << text << endl;
          f.close();
      }
      break;
      case 4:
          cout << "What is the name of the file you would like to delete?" << endl;
     cin.ignore();
     getline(cin,filename);
     remove(filename.c_str());
           cout << filename <<" has been removed."<<endl;
      break;
      default:
      cout << "invalid entry" << endl;
}
	     cout<<"Would you like to continue? (Y/N)" <<endl;
	     cin >> choice;

	}while(choice == 'y' || choice == 'Y');
    return 0;
}
No problem man
Registered users can post here. Sign in or register to post.
Pages: 12