So I need a little help on this, What this program is supposed to do is have the user input there checkbook.txt into the program which looks like this
deposit:July 7:-:300
416:July 8:Albertsons:15.85
417:7/9:Checker Auto:19.95
418:7/10:Super Target:47.50
419:Dec 5:Home Depot:47.89
Once the users enters there data into the program it outputs the text but removes the colons and adds spaces so it looks nice. I would like it to look like this.
--------------------------------------------------------------------
deposit July 7 - $ 300.00
416 July 8 Albertsons $ 15.85
417 7/9 Checker Auto $ 19.95
418 7/10 Super Target $ 47.50
419 Dec 5 Home Depot $ 47.89
--------------------------------------------------------------------
Balance: $168.81
So how do I go about making the items alligned witheachother from reading the txt file?
Also how would I go about getting the balance? Any help would be appreciated thank you. Here is my code this far.
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int main(){
char filename[1000];
cout << "Please Enter Your Checkbook Text: ";
cin.getline(filename, 1000);
ifstream input(filename);
cout << "--------------------------------------------------------------------" << endl;
if(! input.good()){
cerr << "Unable to open " << filename << " for reading" << endl;
exit(1);
}
while (! input.eof()){
char c;
input.get(c);
switch (c){
case ':' : cout << left << setw(2) << "\t" << right << setw(6);
break;
default : cout << c;
break;
}
}
return 0;
}