bank.cpp
One of mah little cousins sent me an e-mail… I was surprised, since the last time I heard from her was like a year ago and it had been in one of those ‘pass this on to a kazillion people now or your sex life will suck for 100 years’ type of things. She told me she would be sending pictures of a new baby cousin (a month old I believe) and a hmm baby nephew too (son of another cousin of mine is a nephew too? Not sure). She did in another e-mail; hehe cute little boogers.
Anyway, seems she’s stuck in a little program she has to do for college. She is planning on doing a dictionary in which she has to list, add, edit, and delete words, plus do some basic sorts. The program should be in c++. Greeeeeat… ~_~ I haven’t seen that language in ages! I guess I was like her age when I did, and it was only for like 2 semesters.
But oh wells, it won’t hurt to look at it. Besides, I am expected to know… I’m the big cousin… graduated twice and with honors… I should know, right?
Heheheh riiight.
So I’ve been reading my C and C++ books to reacquaint myself with the syntax and made a little bank program. I’ve got no parser (since I don’t use C++) so I sent it to her so she can run it. If it works great. Then she can read it an check out what I did so that she can base her program on that. Banks and dictionaries… kinda different, but the bank program inserts, edits, deletes and searches… so it’s the same concept.
We’ll see how it works. Here's a bit of the code:
//Borra un record existente
void deleteRecord(fstream &deleteFromFile)
{
cout << "Escriba el numero de cuenta que sera borrado (1 - 100): ";
int cuenta;
cin >> cuenta;
deleteFromFile.seekg((cuenta - 1) * sizeof(client));
informacionCliente client;
deleteFromFile.read((char *)&client, sizeof(client));
//si el numero de cuenta no esta en zero entonces ponga todo en cero o null
if (client.NumDeCuenta != 0)
{
informacionCliente blankClient = {0, "", "", 0}
deleteFromFile.seekp((cuenta - 1) * sizeof(client));
deleteFromFile.write((char *)&blankClient, sizeof(client));
cout << "No. de cuenta " << cuenta
<< " ha sido borrado." << endl;
}
else
{
cout << "No. de Cuenta " << cuenta << "esta vacio." << endl;
}
}
//enseña un archivo de cliente.
void outputLine(ostream &output, informacionCliente c)
{
output << setiosflags(ios::left) << setw(6) << c.NumDeCuenta
<< setw(16) << c.apellido << setw(11) << c.nombre
<< setiosflags(ios::showpoint | ios::right)
<< setw(10) << setprecision(2) << c.balance << endl;
}
1 Comments:
saleh
Post a Comment
<< Home