我使用以下代码根据用户输入设置缓存大小
int size=1024;
Console::WriteLine("Select the Cache Size.\n a. 1 Kb \n b. 2 Kb \n c. 4 Kb \n d. 8 Kb\n");
String^ CACHE_SIZEoption = Console::ReadLine();
//Char wh=CACHE_SIZEoption->ToChar();
switch(CACHE_SIZEoption[0])
{case 'a':{
size= 1024;
break;}
case 'b':{
size=2048;
break;}
case 'c':{size= 4096;
break;}
case 'd':{size=8192;
break;}
default: {Console::WriteLine("Wrong Input");}
}
#define CACHE_SIZE size
long tags[CACHE_SIZE];
错误在最后一行产生,“long tags[CACHE_SIZE]”
expected constant expression
cannot allocate an array of constant size 0
请告诉是否有另一种方法来做这件事