The question is very simple but I'm confused that why the struct is behaving like this as all of its members are by default public
, have a look at following code
struct Student
{
char name[20];
}
int main()
{
Student s;
s.name="ahmed";
}
This code gives an error that name should be a modifiable lvalue.
But if I assign value in a loop char
by char
, then it works fine like this
s.name[0]='a';//works fine