以下程序不输出所需数据(在 VC2008 编译器上)
#include <stdio.h>
#include <string.h>
int main(void)
{
int i;
int dest[10] = {1};
int src [] = {2, 3, 4, 5, 6};
memcpy(dest, src, 5);
for (i=0; i<10; i++) printf("%i\n", dest[i]);
return 0;
}
而使用char
数组代替,一切都很好!这里的问题在哪里?