请问:第19句为什么会提示”表达式必须是可修改的左值”,因此而不
vs2017吧
全部回复
仅看楼主
level 1
shuiluzhou 楼主
请问:第19句为什么会提示”表达式必须是可修改的左值”,因此而不能运行?
// 第七章例7.5(1).cpp: 定义控制台应用程序的入口点。
//
/*C++程序设计(第3版)谭浩强 编著 P.201
在Visual Studio 2017 上运行
请问:第19句为什么会提示”表达式必须是可修改的左值”? */
#include "stdafx.h"
#include"iostream"
#include"string"
using namespace std;
struct Student//声明结构体类型 Student
{
int num; char name[20]; float score[3];
};
int main()
{
void print(Student);//函数声明,形参类型为结构体Student
Student stu;//定义结构体变量
stu.num = 12345;//以下5行对结构体变量各成员赋值
stu.name = "Li Fang";
stu.score[1] = 89;
stu.score[2] = 78.5;
print(stu);//调用print函数,输出stu各成员的值
return 0;
}
void print(Student stu)
{
cout << stu.num <<" " << stu. name <<" " << stu. score[0] <<" "
<< stu.score[1] << " " << stu.score[2] << endl;
}
2018年03月06日 06点03分 1
1