So basically I'm having a problem that I can't really locate info on via google. Basically I have a struct that I am trying to declare an array of. The size of the array is based on one of the command line arguments. This is the gist of what I am doing here:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
struct Checker{
int breakTime;
int moneyInReg;
int returnTime;
};
//that is before main, then within main I have:
constint numCheckers = atoi(argv[1]);
//and then I declare the struct array like so:
Checker registers[numCheckers];
it is telling me that numCheckers is an undeclared identifier. Why is this?
Thank you all for the help, I hope that was concise enough.
I thought maybe making it a static const int would help, but I am still getting the same error. It seems like it's saying it's undeclared, meaning it's a scope issue, so could it be because I am declaring it within an if statement?
#include <iostream>
usingnamespace std;
struct Checker{
int breakTime = 0;
int moneyInReg = 0;
int returnTime = 0;
};
int main(int argc, char* argv[])
{
//that is before main, then within main I have:
constint numCheckers = atoi(argv[1]);
//and then I declare the struct array like so:
Checker *registers = new Checker[numCheckers];
delete [] registers;
cin.ignore();
return 0;
}