Error Message
Hey there codies, I need some help understanding my error message. Here's the 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
|
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <sstream>
#include <string.h>
using namespace std;
string FileName;
void starline();
float balance;
float deposit;
float check;
double m;
void starline() //function declarator
{
for(int j=0; j<65; j++) //function body
cout << '-';
cout << endl;
}
int main()
{
cout << "Enter a file name (including extension): " << endl;
char FileName[300];
cin.getline (FileName,300);
ifstream input(FileName);
if (!input.good())
{
cerr << "Unable to open file" << endl;
exit(1);
}
while (!input.eof())
{
starline();
char deposit[15];
input.getline(deposit, 15, ':');
cout << left << setw(15) << 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;
starline();
ifstream fin;
double money = 0.0;
fin.open(FileName);
double m = atof ( money);
//test for success, of course
fin >> money; //input stored in the double
}
return 0;
}
|
the 2 errors I get are:
error C2040: 'money' : 'double' differs in levels of indirection from 'char [15]'
error C2088: '>>' : illegal for class
any tips would be appreciated
On line 52, you declare a local variable money
, which is an array of characters.
On line 58, you attempt to declare a second variable with the same name, in the same scope. This is illegal.
Topic archived. No new replies allowed.