我从在线练习测试中找到了这个示例代码,该语句如何
strcpy(e1.name, "K");
有效,但该语句e1.age=10;
无效?任何原因。请澄清。
观察o/p
Gcc 为:K 0 0.000000
#include<stdio.h>
#include<stdlib.h>
struct employee
{
char name[15];
int age;
float salary;
};
const struct employee e1;
int main()
{
strcpy(e1.name, "K"); // How strcpy is being used to store values in a
// constant variable e1 .
//e1.age=10; // not valid
printf("%s %d %f", e1.name, e1.age, e1.salary);
return 0;
}