示例代码无法编译运行

0

EasyX 中InputBox的示例代码没有办法编译

使用环境为Visual Studio 2022,Unicode字符集

提示错误在InputBox函数调用括号内的字母s

"const wchar_t *" 类型的实参与 "LPCTSTR" 类型的形参不兼容

#include <graphics.h>
#include <conio.h>

int main()
{
	// 初始化绘图窗口
	initgraph(640, 480);

	// 定义字符串缓冲区,并接收用户输入
	wchar_t s[10];
	InputBox(s, 10, L"请输入半径");

	// 将用户输入转换为数字
	int r = _wtoi(s);

	// 画圆
	circle(320, 240, r);

	// 按任意键退出
	_getch();
	closegraph();

	return 0;
}
ava
小马哥

2022-7-29

0

确认你的项目字符集,你一定是用了多字节字符集。

你要确认你设置的项目属性的配置和你的编译配置相同,例如在项目里设置了 Release x86 的字符集,那对 Debug x64 没效果。

ava
huidong

2022-7-30

0

试试用 _T("")代替 L""

技术讨论社区