InputBox咋使用

0

帮忙看一下这个,在vs上把InputBox里的s[0].num报错了。

报错:
错误(活动) E0167 "char *" 类型的实参与 "LPTSTR" 类型的形参不兼容 experiment6 E:\vs\vs产物\experiment6\源.cpp 36

typedef struct Student {
	char num[20]={"\0"}; //学号
	char name[20] = { "\0" }; //姓名
	char clas[20] = { "\0" }; //班级
	int scores[3] = { '\0' };;//该生在三门课程中所获得的积分
	int levels[3] = { '\0' }; //三门课程的等级,与scores一一对应
}student;

//成绩录入
void inputgrade() {
	student s[3];
	while (1) {
		InputBox(s[0].num , 20 , L"请输入学生学号");
	}
}
ava
能人儿

2022-11-22

0

字符集错误。

如果你的项目设置的字符集是 Unicode,你就要使用 wchar_t。如果你想使用 char,就要设置项目字符集为 MBCS。

更详细的内容,请参考:https://codebus.cn/yangw/about-unicode

ava
慢羊羊

2022-11-22

0

很简单去掉  :

InputBox(s[0].num , 20 , L"请输入学生学号");

里的宏定义 L 改成:

InputBox(s[0].num, 20, "请输入学生学号");
#include<graphics.h>

#include<conio.h>



typedef struct Student {
	char num[20] = { "\0" }; //学号
	char name[20] = { "\0" }; //姓名
	char clas[20] = { "\0" }; //班级
	int scores[3] = { '\0' };;//该生在三门课程中所获得的积分
	int levels[3] = { '\0' }; //三门课程的等级,与scores一一对应
}student;

//成绩录入
void inputgrade() 
{
	student s[3];
	while (1) 
	{

		InputBox(s[0].num, 20, "请输入学生学号");
	}
}


int main()
{
	initgraph(100,100,1);
	inputgrade();
	_getch();
	closegraph();
	return 0;
}
ava
随波逐流

2022-11-22

技术讨论社区
相关提问