In C code, I'm stuck right here, trying to assign some values to a structure array. I just learned C++ and don't know much on how pointers work. Here is the code as for now:
typedef struct Weather {
float temperature;
float wind;
float humidity;
float precipitation;
} Weather;
const int NUMDATA = 1440;
Weather weather[NUMDATA];
float* generateRandom(float max, float min) {
static float array[NUMDATA];
for (int i=0; i<NUMDATA; i++) {
array[i] = rand() / (float) RAND_MAX * (max - min) + min;
}
return array;
}
void readWeather() {
weather.temperature = generateRandom(40,20);
weather.wind = generateRandom(20,0);
weather.humidity = generateRandom(100,0);
weather.precipitation = generateRandom(20,0);
}
I just run the readWeather() function in the main function and it outputs an error for each line in readWeather() saying that
main.cpp:44:13: error: request for member ‘wind’ in ‘weather’, which is of non-class type ‘Weather [1440]