Write your question here.
I keep getting an error saying missing type specifier, int assumed.
and cannot convert argument 1 from Rainfall to const int. Can someone help?
#include <iostream>
#include <iomanip>
#include <string>
usingnamespace std;
void userInput(const Rainfall &k);
struct Rainfall
{
std::string month;
int amount;
};
int main(){
Rainfall s;
constint SIZE=12;
userInput(s[SIZE]);
return 0;
}
void userInput(const Rainfall &k){
cout << "Enter the rainfall(in inches) for January:" << endl;
cout << "Enter the rainfall(in inches) for February : " << endl;
cout << "Enter the rainfall(in inches) for March : " << endl;
cout << "Enter the rainfall(in inches) for April : " << endl;
cout << "Enter the rainfall(in inches) for May : " << endl;
cout << "Enter the rainfall(in inches) for June : " << endl;
cout << "Enter the rainfall(in inches) for July : " << endl;
cout << "Enter the rainfall(in inches) for August : " << endl;
cout << "Enter the rainfall(in inches) for September : " << endl;
cout << "Enter the rainfall(in inches) for October : " << endl;
cout << "Enter the rainfall(in inches) for November : " << endl;
cout << "Enter the rainfall(in inches) for December :" << endl;
}
#include <iostream>
#include <iomanip>
#include <string>
usingnamespace std;
constint SIZE=12;
struct Rainfall{
std::string month;
int amount;
};
void userInput( Rainfall k[], int size);
int main(){
Rainfall s[SIZE];
userInput(s, SIZE);
return 0;
}
void userInput(Rainfall k[], int size){
cout << "Enter the rainfall(in inches) for January:" << endl;
cout << "Enter the rainfall(in inches) for February : " << endl;
cout << "Enter the rainfall(in inches) for March : " << endl;
cout << "Enter the rainfall(in inches) for April : " << endl;
cout << "Enter the rainfall(in inches) for May : " << endl;
cout << "Enter the rainfall(in inches) for June : " << endl;
cout << "Enter the rainfall(in inches) for July : " << endl;
cout << "Enter the rainfall(in inches) for August : " << endl;
cout << "Enter the rainfall(in inches) for September : " << endl;
cout << "Enter the rainfall(in inches) for October : " << endl;
cout << "Enter the rainfall(in inches) for November : " << endl;
cout << "Enter the rainfall(in inches) for December :" << endl;
}
Here is working version. Compiler reads line by line. struct was under function declaration so compiler didnt know it existed. If you want to create array you have to point it out at declaration no when you pass it as argument. and when you add const in front of the thing that means you can't change info in it.