c - struct variable initialization -


I tried to start the struct variable as the following:

  struct abc {Char str [10]; }; Int main () {struct ABC s1; S1.str = "Hello", // error}  

I can understand this behavior because it is the same

  four letters [10]; Str = "Hello", // Incompatible type  

but see the following initialization

  struct ABC s1 = {"hello"}; // This fine structure ABC s2 = {. Str = "hello"}; // It is also OK  

I remember in my undergraduate level studies, I have read many text books, which states that these two initiatives are the same thing (i.e. Using the {} marking using the initial string is the same thing and clearly (.) Operator is the same thing). But the above discussion proves that they are not equal.

My question is, what is the difference between these initials?

The difference is, these two lines

  Struct ABC s1 = {"hello"}; // This fine structure ABC s2 = {. Str = "hello"}; // It is also OK  

initialization , while it

  s1.str = "hello";  

Assignment You can start a four array for the string, but not through the assignment.


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -