关于strncpy的问题。
char a[5],b[5],e[10],f[10];
int c,d,i;
ZeroMemory(a,5);
ZeroMemory(b,5);
ZeroMemory(e,10);
ZeroMemory(f,10);
c=1000;
d=1001;
strncpy(a,(char*)&c,sizeof(int));
strncpy(b,(char*)&d,sizeof(int));
strncpy(e,a,sizeof(int));
strncpy(e+sizeof(int),b,sizeof(int));
strncpy(f,e,10);
----------------
本来我的意思就是想f这个字符串的内容和e字符串完全相同的,但执行最后一句的时候居然不成功。
如果把最后一句话改成:
for(i=0;i<10;i++)
{
strcpy(&f[i],&e[i]);
}
的话,就可以。那请问这是什么问题?