There exists a structure I defined as follows:
struct details
{
char name[20];
int age;
char country[20];
};
In this specific instance, however, declaring an object of the structure and assigning a string literal as value to either of the two character array members yields an error. The error erupts when I assign values through the following way:
int main()
{
struct details d1;
d1.name="Constantine";
d1.country="Byzantium";
exit(EXIT_SUCCESS);
}
The error that my GCC C compiler yields is as follows:
error: incompatible types in assignment of 'const char [12]' to 'char [20]'
Does this occur owing to the fact that the string literal is a constant character array whereas the character array members I have declared as constituents of the said structure are not constant in nature? Would declaring the said structure members as constant resolve the error at hand? Or do I have embrace a different approach to load initial values to the said structure members?