The char array is a part of network message, which has well defined length, so the null terminator is not needed.
struct Cmd {
char cmd[4];
int arg;
}
struct Cmd cmd { "ABCD" , 0 }; // this would be buffer overflow
How can I initialize this cmd member char array? without using functions like strncpy?
=the given initialization is fine.{'A','B','C','D'}initializer is therefore good practice: it is self-documenting code showing that the programmer is aware of the lack of null termination, but it also allows compilers/static analysers to give a warning elsewhere in the code, when a string literal initializer results in a string that is not null terminated.