【发布时间】:2013-03-03 01:49:29
【问题描述】:
我正在尝试制作基于文本的角色扮演游戏,目前正在实现 diceroll 功能:
int diceRoll(){
int n;
srand(time(0));
n = rand() % 4;
return n;
}
int main()
{
int RandNum = diceRoll();
cout<< " Randomly generated number: " + RandNum;
return 0;
}
但它会输出这个:
【问题讨论】:
-
stackoverflow.com/a/1117317/962089。由于它已被删除,
const char (&)[N] + int不会按您的预期工作。 -
在将 RandNum 输出到 cout 时尝试使用