The strncpy function copies the initial count characters of strSource to strDest and returns strDest. If count is less than or equal to the length of strSource, a null character is not appended automatically to the copied string. If count is greater than the length of strSource, the destination string is padded with null characters up to length count. The behavior of strncpy is undefined if the source and destination strings overlap.
错误的使用
strncpy(di.group, adg.group, sizeof(di.group) - 1);
正确的应该为
strncpy(di.group, adg.group, sizeof(di.group) - 1);
di.group[sizeof() - 1] = 0;