Where
char member[50];
Inside
Struct structure_variable
Why am I unable to initialise structure_variable.member='Dev';
in C?
Where
char member[50];
Inside
Struct structure_variable
Why am I unable to initialise structure_variable.member='Dev';
in C?
What you need is an assignment, not an initialization.
The correct way for assigning a null-terminated char array (a string) is using strcpy()
:
strcpy(structure_variable.member, "Dev");
meaning that you copy all the characters of the string "Dev"
(included the string terminator '\0'
at the end) in the memory location starting from the char
pointer member
.
Note: I assumed that the use of 'Dev'
in your question is a typo, as strings need to be enclosed by double quotes as you correctly stated in your question.