I seriously need some help! I get error "cpp.51 error: Incompatible type in assignment of 'double' to 'double[12]'." I am trying to get this program to write some information into a structure, and then write that structure to an output file. Also, I cannot get this to work because I cannot open toe file from program 2. Can anyone help???
Line 12: double monthlyExpenses[NUM_MON]; //Its an array of doubles
Line 51: read.monthlyExpenses = atof(s); //you are trying to assign a double to array
either use
1 2
double monthlyExpenses; //a double variable
read.monthlyExpenses = atof(s); //now it will be correct
or
1 2
double monthlyExpenses[NUM_MON]; //a double variable array
read.monthlyExpenses[some_int] = atof(s); //now it will be correct
Line 51 of program 1 must (certainly) be: read.monthlyExpenses[i] = atof(s); // Note [] for array access
For program 2: "binary_expenses" is likely not where the program expect it. Use an absolute path instead (e.g. "c:\\tmp\\binary_expenses" // Note \\ for windows )
the error cpp.51 error: Incompatible type in assignment of 'double' to 'double[12]
says in the program line 51 you are trying to assign a value of data type to a variable of different data type.
Yes, very clear. There are no more errors, now it's not displaying anything. Also the file created has nothing in it. The output just recognizes the system pause, but nothing else. Any suggestions?
I was thinking void printUtilityStat (utilityInfo teamAr[], int numUtilities)
Is this close?
sample output:
*** gas ***
sum over 12 months: $1400.23 average: $ 116.69
highest cost: $ 207.14 lowest cost: $ 52.55
*** electricity ***
sum over 12 months: $1149.10 average: $ 95.76
highest cost: $ 188.32 lowest cost: $ 50.90
*** water ***
sum over 12 months: $ 629.84 average: $ 52.49
highest cost: $ 78.33 lowest cost: $ 40.56
*** cable ***
sum over 12 months: $1310.95 average: $ 109.25
highest cost: $ 152.64 lowest cost: $ 46.93
*** phone ***
sum over 12 months: $ 957.65 average: $ 79.80
highest cost: $ 83.57 lowest cost: $ 79.15