So I have a method, that takes in my vector and does a for loop where it checks if the year and month entered in by the user exists in the file, the data from those matches is taken in and some calculations performed. Now I have to do another condition, where the user only enters in the year and I need to get all records for all the months that have information in that year.


What I have so far:


Code:
int month;
        int year;
        int SIZE = windlog.size();
        float averagetemp[SIZE];
        float sd[SIZE];
        float sum = 0;
        float sigma = 0;
        float avgtemp1;
        float sd1;
        int nrofel = 0;
        int check[SIZE];
    
        cout << "Please enter a year: " << endl;
        cin >> year;
    
        for(int i = 0; i < windlog.size(); i++){
    
            if(windlog[i].d.GetYear() == year){
    
                for(int x = 1; x < 13; x++){
    
                    if(windlog[i].d.GetMonth() == x){
    
                        nrofel++;
                        sum += windlog[i].temp.GetTemperature();
                        averagetemp[i] = (sum/nrofel);
                        sigma += (windlog[i].temp.GetTemperature() - averagetemp[i])*(windlog[i].temp.GetTemperature() - averagetemp[i]);
                        sd[i] = (sigma)/(nrofel - 1);
                        check[i] = x;
    
                    }
    
                }
    
    
            }
    
        }
    
        int z = 0;
        for(int y = 1; y < 13; y++){
    
            if(check[z] != y){
    
                cout << checkMonth(y) << ": No Data" << '\n';
                z++;
    
            }
            else{
    
                cout << checkMonth(y) << ": " << averagetemp[z] << " degrees C, stdev: " << sd[z] << '\n';
    
            }
    
        }
    
    }
So far my output shows 'No Data' for every month except March in the year 2014, however there is data from March till December. Pretty sure my logic is incorrect, can anyone point me in the right direction?


If the input file is needed let me know. Just to clarify, the first column consists of both the date and time, and I split the values in the program.