views:

158

answers:

2

The following code returns this: error: expected unqualified-id before ‘for’

I can't find what is causing the error. Thanks for the help!

#include<iostream>

using namespace std;

const int num_months = 12;

struct month {
    string name;
    int n_days;
};

month *months = new month [num_months];

string m[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", 
              "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
int n[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

for (int i=0; i<num_months; i++) {
    // will initialize the months
}

int main() {
    // will print name[i]: days[i]
    return 0;
}
A: 

You can't use for at that scope.

dreamlax
+3  A: 

Your for loop is outside a function body.

missingfaktor
That was pretty fast! :) Thx
Morlock