#include <iostream>
using namespace std;
struct student
{
};
int main( )
{
}
道理和以下语句错误的原因一样,数组名表示常量,不允许对常量赋值,所以常量不允许出现在“=”的左边,当做左值出现。所以不能直接用字符串赋值给数组名。但请注意:可以在定义字符数组的同时用字符串给字符数组赋初值。
char name[20]="gyy";
但先定义,再赋值的方式就是错误的。
char name[20];
#include <iostream>
using namespace std;
struct student
{
};
int main( )
{
}
对开始的程序修改方式(2)
#include <iostream>
using namespace std;
struct student
{
};
int main( )
{
}