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;
}
– Adjust the Curly Braces To Fix the Expected Unqualified Id Error. You should match the opening and closing curly braces in your code to ensure the right quantity of brackets. The code should not have an extra or a missing curly bracket.
expected unqualified-id before numeric constantCython is a tool to wrap C/C++ code so that it can interface with a Python interpreter. Cython generates the wrapping code and sends it to GCC.
Your for
loop is outside a function body.
Ok just to make this answer clear (since I made the rookie mistake too).
the for loop was outside int main()
(or any other function) along with everything else since main() sits by itself empty at the bottom of the code.
Sorry more than needed to be said for some but since this issue is more directed to newbies a more elaborate explanation is needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With