To extend the answer recommending strcpy()
I'd use memcpy()
and use a #defined length to make sure you always use the same value.
#define NOME_LENGTH 60
struct s_Especialidade{
int id;
char nome[NOME_LENGTH];
char descricao[60];
struct s_Especialidade *proximo;
};
typedef struct s_Especialidade Especialidade;
PESPECIALIDADE p, *array;
memcpy(p->nome, array[i]->nome, NOME_LENGTH);
Things get even more complicated trying to consider what an assignment does, but, in an example program:
struct stuff {
char buf[2];
};
int main() {
struct stuff a;
memcpy(a.buf, "aa", 2); // *Edit: "aa" is a bad example as it
// actually becomes at compilation 3 bytes long
// {'a','a','\0'} as noted in the comments
struct stuff b;
b.buf = a.buf; // *Edit: For illustrative purposes, an assignment
// between two char[2] members is not correct and
// does not compile.
}
Compilation yeilds the error error: incompatible types when assigning to type ‘char[2]’ from type ‘char *’
for the b.buf = a.buf
line.
The topic of pointers and arrays has been covered elsewhere, Is an array name a pointer? among others.
*Edit: As noted in the comments, in the above code if instead of b.buf = a.buf;
the struct assignemnt b = a;
were done, the internal members would be copied correctly. This is because struct to struct assignment is effectively memcpy(&b, &a, sizeof(b));
(Assign one struct to another in C)