cannot allocate an array of constant size 0

Jun 3, 2013 at 7:23am
Hi! am reading the csv file,however it works when I initialize the data statically.But, the value needs to be declared dynamically and am doing this using vectors. And yet am not able to debug the error.

error C2057: expected constant expression
error C2466: cannot allocate an array of constant size 0

The code pasted here is for static:
struct info
{
string m_register;
string dev_id;
string desc;
string type_id;
string config_id;
string status;
string commandTAG;
string EVENT;
};
const int n=1500;// statically declared;1500 is the total no of values to be read from csv file.

typedef map <int,string> add_map;
typedef map <int,string> add_map_addr;

static int switchcase;
#endif

I have declared the same dynamically below,yet it throws the same error.

{
string m_register;
string dev_id;
string desc;
string type_id;
string config_id;
string status;
string commandTAG;
string EVENT;
};
std::vector<mbusinfo *> n;// dynamic declaration

typedef map <int,string> add_map;
typedef map <int,string> add_map_addr;

static int switchcase;
#endif

Any help would be appreciated, thanks in advance.


Jun 3, 2013 at 8:01am
We need to see the actual line that's generating the error along with the relevant definitions/declarations.

It's not clear from what you've posted what line the error is on.
Topic archived. No new replies allowed.