How to fix these errors
Mar 18, 2014 at 9:23am UTC
1 2 3 4 5 6 7 8 9 10 11
string menuNames[menuAmount];
for (int i=0;i<menuAmount;i++)
{
menuNames[i]=menuNamesAfterParse.substr(0, menuNamesAfterParse.find_first_of('|' ) );
if (i!=(menuAmmount-1))
{
menuNamesAfterParse = menuNamesAfterParse.substr(menuNamesAfterParse.find_first_of('|' ));
menuNamesAfterParse = menuNamesAfterParse.substr(1);
}
}
error C2057: expected constant expression
error C2466: cannot allocate an array of constant size 0
error C2133: 'menuNames' : unknown size
Mar 18, 2014 at 9:41am UTC
The array size need to be a compile time constant. If you want the size of the array to be decided at runtime you can allocate the array with new
or use std::vector
.
Topic archived. No new replies allowed.