Why did the code keep saying expected-primary expression? #include #include #include using namespace std; void readFile ( float, float); void average(float, float); void highest_lowest(float, float, int); void writeReport(float, float, float, float, int); struct WeatherData { float rain; float hiT, lowT, avgT; //rain in a month, high temperature, low temperature, average temperature respectively int rain_days; string month; }; void readFile (WeatherData mth[], float tot_rain, float avgR) { //name_mth=month ifstream fin; int i, n_mth; for(i=0; i> WeatherData mth[i].rain; fin >> WeatherData mth[i].rain_days; fin >> WeatherData mth[i].hiT; fin >> WeatherData mth[i].lowT; fin >> WeatherData mth[i].month; WeatherData mth[i].avgT = (WeatherData mth[i].hiT + WeatherData mth[i].lowT) / 2; tot_rain = tot_rain + WeatherData mth[i].rain; } avgR = tot_rain/12; highest_lowest(WeatherData mth, tot_rain, avgR) } void highest_lowest(WeatherData mth[], float tot_rain, float avgR) { float high=0.00, low=35; int j, n_mth, hi_mth, low_mth; string nhi_mth, nlow_mth; for(j=0; j low_mth) { low_mth = WeatherData mth[j].lowT; nlow_mth = WeatherData mth[j].month; low_mth = j + 1; } } } void writeReport(WeatherData mth[], float rain, float hiT, float lowT, float avgT, int rain_days) { ofstream fout; fout.open("Output.txt"); float tot_rain, avgR, high, low, hi_mth, nhi_mth, low_mth, nlow_mth; int i, n_mth; fout << "Total Rainfall: " << fixed << setprecision(2) << tot_rain << endl; fout << "Average Monthly Rain: " << fixed << setprecision(2) << avgR << endl; fout << "Highest temperature: " << high << "(Month " << hi_mth << ": " << nhi_mth << ")" << endl; fout << "Lowest temperature: " << low << "(Month " << low_mth << ": " << nlow_mth << ")" << endl; fout << "Month" << "\t\tRain" << "\tRain days" << "\tHi TEMP" << "\tLo TEMP" << "\tAvg TEMP" << endl; fout << "=========" << "\t======" << "\t=========" << "\t=======" << "\t=======" << "\t========" << endl; for(i=0; i
Why did the code keep saying expected-primary expression?
#include <iostream> using namespace std; void readFile ( float, float); struct WeatherData { void readFile (WeatherData mth[], float tot_rain, float avgR) { //name_mth=month ifstream fin; void highest_lowest(WeatherData mth[], float tot_rain, float avgR) { void writeReport(WeatherData mth[], float rain, float hiT, float lowT, float avgT, int rain_days) { int main() { |
Step by step
Solved in 2 steps