You fell straight into the trap.
In C, C++, Objective-C, Objective-C++, a parameter with a declaration that looks like "array of T" actually has type T*.
Your parameter charArray has a declaration that looks like "array of 100 chars", but the declaration is in fact "pointer to char".
Therefore, your third parameter to strncpy has a value of (most likely) 4 or 8, and not the 100 that you seem to expecct.
BTW. strncpy is highly dangerous the way you use it.
link: https://stackoverflow.com/questions/29186056/gcc-4-9-2-bug-in-werror-sizeof-pointer-memaccess
下面的代码中警告是什么原因,怎么解决
memset(m_pBuffer,0,sizeof(m_pBuffer));
warning: argument to 'sizeof' in 'void* memset(void*, int, size_t)' call is the same expression as the destinati