Code crashes while running

Hi all,

My code crashes halfway while running till the EditCashFlow() portion.
It will crash once the user input the choice he want to edit.

Below is a long chunk of code.
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <sstream>



using namespace std;

int main();

class Login
{
public:
    void UserValidate();
    void LoginSuccess();
    
private:       
    string UserID;
    string password;
    string UserEntered;
    string PassEntered;
};


class OptionA
{
public:
       void AddCashFlow();
       
private:
        int income, expense;
        string date, desc;          
};

class OptionB
{
public:
       void RemoveCashFlow();

private:
        vector <string> file;
        int choice;
};
  

class OptionC
{
public:
       void EditCashFlow();

private:
        vector <string> file;
        int choice;
        
};
  
  
  
class OptionD
{
public:
       void ViewSummaryReport();
       
private:
        vector <int> amount; 
        string data;             


};


  void Login :: UserValidate()
    {    
         int count = 1;
         while (count < 4)
         {
          
          cout << "Enter your username" << endl;
          getline(cin, UserEntered);
          cout << "Enter your password" << endl; 
          getline(cin, PassEntered);
         
          ifstream userfile;
          userfile.open ("users.txt");
          userfile >> UserID;
          userfile >> password;
          int i = 0;
          
          int offset = 4;

         while (i < password.length())
               {
               password[i] = int (password[i]) - offset;
               i++;
               }           
               if (UserEntered == UserID && PassEntered == password)
               {
               cout << "Login Successfully!" << endl;
               Login Success;
               Success.LoginSuccess();    
               }
               else
               {
               cout << "Login Failed!" << endl;
               count++;
               }
         }
         cout << "Account locked!" << endl;
         system("PAUSE");  
    }

void Login :: LoginSuccess()
{
    cout << "******************************************************" << endl;
    cout << "*a)Add new cashflow                                  *" << endl;
    cout << "*b)Remove cashflow                                   *" << endl;
    cout << "*c)Edit cash flow item for either income or expenses *" << endl;
    cout << "*d)View Net Cash flow summary report                 *" << endl;
    cout << "*e)Quit                                              *" << endl;
    cout << "******************************************************" << endl;

    string select;
    cout << "Please enter your selection" << endl;
    cin >> select;

        if (select == "a")
        {
           OptionA cash;
           cash.AddCashFlow(); 
        }
        if (select == "b")
        {
           OptionB b;
           b.RemoveCashFlow();           
        }
        if( select == "c")
        {
            OptionC c;
            c.EditCashFlow();    
        }
        if (select == "d")
        {
           OptionD d;
           d.ViewSummaryReport();           
        }
        if (select == "e")
        {
         main();
        }
}


void OptionA :: AddCashFlow()
{
    int select;
    
    cout <<"**********************" << endl;
    cout <<"*1)expense           *" << endl;
    cout <<"*2)income            *" << endl;
    cout <<"**********************" << endl;
    cout <<"Please select expense or income" << endl;
    cin >> select;

    if (select == 1)
    {
    cout << "Enter your expense" << endl;
    cin >> expense;
    cout << "Enter item description" << endl;
    cin >> desc;
    cout << "Enter date in DD Month Year format with no spaces" << endl;
    cin >> date;
    expense *= -1;  
    ofstream cashflow;
    cashflow.open ("cashflow.txt" , fstream::app);
    cashflow << desc << ":" << expense << ":" << date << endl;
    cashflow.close();
    Login menu;
    menu.LoginSuccess();
           
    }
    
    if (select == 2)
    {
    cout << "Enter your income" << endl;
    cin >> income;
    cout << "Enter item description" << endl;
    cin >> desc;
    cout << "Enter date in DD Month Year format" << endl;
    cin >> date;
    ofstream cashflow;
    cashflow.open ("cashflow.txt" , fstream::app);
    cashflow << desc << ":" << income << ":" << date << endl;
    cashflow.close();
    Login menu;
    menu.LoginSuccess();
    }
    
}

void OptionB :: RemoveCashFlow()
{
     
     ifstream cashflow;
     cashflow.open ("cashflow.txt");
     string data;     
     while (! cashflow.eof())
     {
     getline(cashflow, data);
          if (!cashflow.eof()) 
          {  
          file.push_back(data);                            
          }
               
     }
      cashflow.close();
      for(int i = 0; i < (int)file.size(); i++)
      {
           cout << i + 1  << ") " << file[i] << endl;                      
      }
      
       
       cout << "Enter which entry to remove or press 0 to go back main menu" << endl;  
       cin >> choice;  
      if (choice != 0)
      {
      file.erase(file.begin() + (choice - 1));
      cout << "Detail Deleted" << endl;
      
      ofstream newcashflow("cashflow.txt", ios::out | ios::trunc);
      for(vector<string>::const_iterator i = file.begin(); i != file.end(); i++)
                {
                newcashflow << *i <<endl;
                }
                cashflow.close();
                
      }             
      Login menu;
      menu.LoginSuccess();
                          
}

void OptionC :: EditCashFlow()
{
     ifstream cashflow;
     cashflow.open ("cashflow.txt");
     string data; 
     while (! cashflow.eof())
     {
     getline(cashflow, data);
          if (!cashflow.eof()) 
          {  
          file.push_back(data);                            
          }       
     }
      cashflow.close();
      for(int i = 0; i < (int)file.size(); i++)
      {
           cout << i + 1  << ") " << file[i] << endl;                      
      }
      
      cout << "Enter which entry to edit or press 0 to go back main menu" << endl;  
      cin >> choice;  
      cout << "Enter new data starting from Item Desc, Amount and Date with colons to separator them" << endl;
      getline(cin, file[choice]);
      
      for(int x = 0; x < file.size(); x++)
      {
           cout  << file[x - 1] << endl;                      
      }
      
      
       
}

void OptionD :: ViewSummaryReport()
{

          ifstream cashflow;
          cashflow.open ("cashflow.txt"); 
          string name, separator;
          int money;
          int total_incomes = 0;
          int total_expenses = 0;
          int netflow = 0;
          string columns[2];
          string enter;
       while(! cashflow.eof())  
       {  
          if(! cashflow.eof())
          {
             for(int x = 0; x < 2; x++)
             {   
             getline(cashflow, columns[x], ':'); 
             }   
          } 
          cout << columns[1] << endl; 
       } 
          
        
      /*cout << "Please 0 to go back main page" << endl;
      cin >> enter;
      
      if (enter == "0")
      {
           Login menu;
           menu.LoginSuccess();    
      }
      */
}      
             
     
    int main()
  {
         Login User;   
         User.UserValidate();       
  }
 








you mean on this line?

getline(cin, file[choice]);

could you post the files also, how they look like.
My program crash upon hitting this line.

1
2
cout << "Enter which entry to edit or press 0 to go back main menu" << endl;  
cin >> choice; 


Once I enter my choice that I want to edit it crashes.

My data file looks like this:
1
2
3
psp:-200:12June2011
csc:-212:1July2011
salary:2000:28July2011
Topic archived. No new replies allowed.