I'm having trouble assigning words in a character.
CodePudding user response:
You can't initialize a char[]
array like that when it is a member of a struct
(also, ==
is the equality comparison operator, =
is the assignment operator).
You will have to use strcpy()
/strncpy()
instead after creating an instance of the struct
, eg:
struct Livro livro;
strncpy(livro.editor, "Abril", 10);
CodePudding user response:
In C you can do so via the following method:
char editor[10];
strncpy(editor, "Abril", 10);
CodePudding user response:
In C, you cant directly initialize a string (char ) in a struct, and you have to initialize your struct into a function before. And after that you'll have to use your char[] or char like this :