I'm trying to write a function that takes adds all of the numbers from an array. I'm not understanding the error code
invalid conversion from 'int' to 'int*' [-fpermissive]
total = total_sales(sales[i]);
#include <iostream>
#include <fstream>
#include <string>
usingnamespace std;
int main()
{
int i=0, sum, total, sales[21], total_sales(int sales[]);
ifstream in_stream;
char sales_file[16];
cout << "What is the name of the file for the sales?\n";
cin >> sales_file;
in_stream.open(sales_file);
while(!in_stream.eof())
{
in_stream >> sales[i];
i++;
}
int num_of_locations = sales[0];
total = total_sales(sales[i]);
cout << "The total of all sales at all locations is " << total << " .\n";
in_stream.close();
int total_sales(int sales[]);
for (i=1, i<21, i++)
{
sum = 0;
sum += sales[i];
}
return sum
}
}
#include <iostream>
#include <fstream>
#include <string>
usingnamespace std;
int main()
{
int i=0, sum, total, sales[21], total_sales;
ifstream in_stream;
char sales_file[16];
cout << "What is the name of the file for the sales?\n";
cin >> sales_file;
in_stream.open(sales_file);
while(!in_stream.eof())
{
in_stream >> sales[i];
i++;
}
int num_of_locations = sales[0];
total = total_sales;
cout << "The total of all sales at all locations is " << total << " .\n";
in_stream.close();
for (i=1; i<21; i++)
{
sum = 0;
sum += sales[i];
}
return sum;
}
Here is the code and contains no compiler errors. It is up to you to fix all remaining mistakes in your program.