Question about char to int from a text file


Hello, I'm having a little trouble with this checkbook program and taking the string from the text file and assigning the string to an int and performing a mathematical operation. My code is here, it compiles and runs fine, it just displays an incorrect value for the remaining balance. I'm just hoping someone here can put me on the right track.
Thank you.
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
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;

string file;
void line();
double balance;
double d, m;
int main()
{
	cout << "Enter a file name (including extension): " << endl;
	cin >> skipws >> file;
	ifstream input(file);

	if (!input.good())
	{
		cerr << "Unable to open file" << endl;
		exit(1);
	}
	line();
	while (!input.eof())
	{
		char    deposit[15];
		input.getline(deposit, 15, ':');
		cout << left << setw(15) << deposit;
		d = atof(deposit);
		char    date[15];
		input.getline(date, 15, ':');
		cout << setw(15) << date;
		char    place[15];
		input.getline(place, 15, ':');
		cout << setw(15) << place;
		char money[15];
		input.getline(money, 15);
		cout << right << setw(15) << "$   " << money << right << endl;
		m = atof(money);

		balance = d - m;
	}
	line();
	cout << right << setw(55) << "Balance : " << " $  " << balance << right << endl;

	return 0;
}
void line()
{
	for (int j = 0; j < 65; j++)
		cout << '-';
	cout << endl;
}

Oh I almost forgot the text I'm using for this program.
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
Thanks again.
balance = d - m; Here you are deducting some amount from... deposit number?
Also only last calculation of balance would be saved.
I believe you intended to do balance -= m, but you still lack initial balance amount.
Thank you both for the help, I haven't quite solved it yet but I'm a lot closer than I was this morning.
Topic archived. No new replies allowed.