Can someone explain
Why does the below code work for saving a string in a struct member
struct prefix {
char aString[70];
};
struct prefix data={
.aString = "d08430c90b467422ae9bf7f8ecf8a77682f92764efe53e0ebe26d4ffb6fb96bf"
};
while the code below does not?
struct prefix {
char aString[70];
};
struct prefix data;
data.aString = "d08430c90b467422ae9bf7f8ecf8a77682f92764efe53e0ebe26d4ffb6fb96bf";
//Array type 'char [70]' is not assignable
CodePudding user response:
initialization: create an object and specify its value in one instruction;
assignment: change the value of a pre-existing object
struct prefix data = { ... }; // initialization;
struct prefix data; // not initialized now, cannot ever initialize it later, only assign
