【发布时间】:2016-10-12 20:32:42
【问题描述】:
我正在开发一个小程序,该程序最多可以计算用户给出的数字。他们输入的数字存储在变量limit 中。我希望该变量中的数字显示在类似这样的标题中:“最多计数 3000”或“限制设置为 3000”或类似的东西。我试过使用SetConsoleTitle(limit); 和其他东西,但它们不起作用。使用我在下面发布的代码,我收到以下错误:
“int”类型的参数与“LPCWSTR”类型的参数不兼容
如果这很重要的话,我目前正在使用 Visual Studio 2015。
#include <iostream>
#include <windows.h>
#include <stdlib.h>
using namespace std;
int main()
{
begin:
int limit;
cout << "Enter a number you would like to count up to and press any key to start" << endl;
cin >> limit;
SetConsoleTitle(limit); // This is my problem
int x = 0;
while (x >= 0)
{
cout << x << endl;
x++;
if (x == limit)
{
cout << "Reached limit of " << limit << endl;
system("pause");
system("cls");
goto begin;
}
}
system("pause");
return 0;
}
【问题讨论】:
标签: c++ variables console title