I tried to initialize struct variable as following:
struct Abc{
char str[10];
};
int main(){
struct Abc s1;
s1.str="Hello"; //error
}
I can understand this behavior because it is same as
char str[10];
str="Hello"; // incompatible types
But look at following initializations
struct Abc s1={"Hello"}; //This is fine
struct Abc s2={.str="Hello"}; //This is also fine
I remember in my graduation, I read lot of text books which said these both initializations are one and same thing (i.e initialing struct variables using { } notation and explicitly using (.) operator are same thing ). But above discussion proves that they are not same.
My question is what exactly is difference between these initializations?