字符数组char *s; 不能scanf输入,运行中不能赋值

//运行中不能改变
#include <iostream>
using namespace std;
struct student{
	int id;
	char *name;
}stu[10];
void main()
{

	stu[1].id=123;
	stu[1].name="qwe";
	//scanf("%d %s",&stu[1].id,&stu[1].name);
	
	printf("%d %s\n",stu[1].id,stu[1].name);
}
发布了128 篇原创文章 · 获赞 26 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/yky__xukai/article/details/102846948