Hello, attempted a computer science degree at one time, then figured it wasnt for me, and now I want to be a paramedic. Anywho, I somehow got thru the first 2 courses of compsci, along with the first assembly language course, so I have some programming in my brain, but I can't remember the really complex stuff like stacks, pointers, headers, that sort of stuff. I went to write a program the other day for fun, just to see if I could do it, and I remembered some shit. I then attempted to write a "bank" program for ppl who owe me money. Now, my main problem is that each time I run the program, it erases the data that was sent to the file. I'm sure I'm forgetting something really simple, or else my design isn't complex enough, but if there is a solution without using a bunch of pointers and a stack and such, that'd be great, but if not, could someone plz remind me how to do that stuff. Anyways, here is the source code I have thus far:
#include<iostream>
#include<cstring>
#include<fstream>
using namespace std;
char accnt(string &out);
int stats(string &out, int &dollaz, char &paid);
string name;
int sel;
bool end = 1;
char choice;
int main ()
{
ifstream input;
input.open("Accounts.txt");
string aname;
int moneyz;
char paidup;
cout<<"Oh hello, who the fuck might you be?\n";
getline(cin,name);
while ( end != 0)
{
input.open("Accounts.txt");
cout<<"Well " << name << " we is in bank. Make a selection:\n";
cout<<"1. Account Stats\n";
cout<<"2. Credit Ratings\n";
cout<<"3. Edit Info\n";
cout<<"You choose...";
cin>>sel;
if(sel == 1)
{
input.open("Accounts.txt");
while(end != 0)
{
accnt(aname);
cout<<"Your Account for"<<" "<<aname<<":\n";
stats(aname,moneyz,paidup);
cout<<"You wanna see any other stats?\n";
cin>>choice;
if(choice == 'y')
end = 1;
else
{
cout<<"Bye Bitch!\n";
end = 0;
}
}
input.close();
}
else if(sel == 2)
{
input.open("Accounts.txt");
cout<<"Enter name of person:";
cin>>aname;
cout<<"Hmm... Credit rating of"<<" "<<aname<<" "<<"is..."<<" ";
if(paidup == 'y')
cout<<"rating is good, for now...\n";
else
cout<<"AW SHIT, THIS MOTHER FUCKER ISN'T GONNA BE USING MY BANK AGAIN! HORRIBLE!\n";
input.close();
}
else if(sel == 3)
{
ofstream oot("Accounts.txt");
input.open("Accounts.txt");
cout<<"Who's Account will you be fuckin with?\n";
cin>>aname;
oot<<aname;
cout<<"Account for"<<" "<<aname<<" ";
cout<<"How much does"<<" "<<aname<<" "<<" owe?\n";
cin>>moneyz;
oot<<moneyz;
cout<<"Is"<<" "<<aname<<" "<<"paid up?(y or n)\n";
cin>>paidup;
oot<<paidup;
input.close();
oot.close();
}
else
cout<<"Invalid Selection.";
cout<<"Are you finished today?(y or n)\n";
cin>>choice;
if(choice == 'y')
{
cout<<"Bye Bitch!\n";
end = 0;
}
else
end = 1;
input.close();
}
input.close();
}
char accnt(string &out)
{
bool final = 1;
char aans;
Yes I have a twisted sense of humor, the comments are not aimed at anyone in particular, I simply find them amusing to add in, so plz don't take offence. Any help is greatly appreciated.
I'll be playin bass until a reply,
Thanks,
Uncle Ernie
--------
| o o |
| |
| || |
| |
| |
| ------|
---------