FILE *fp;

short *originalUnPacked;
short *unPacked;

int fileSize;

fp = fopen(FILENAME, "r");
fseek (fp , 0 , SEEK_END);
fileSize = ftell (fp);
rewind (fp);

originalUnPacked = (short*) malloc (sizeof(char)*fileSize);
unPacked = (short*) malloc (sizeof(char)*fileSize);

printf ( "The UnPacked  : %d ", unPacked);
printf ( "The Original UnPacked  : %d ", originalUnPacked);


//上面的print语句打印两个不同的值,我的问题是为什么?

最佳答案

我认为您不应该将*传递给printf。它期望一个简单的简短,对不对?

如果打印短*,则不会得到大小,而是会得到该内存所在的地址。

09-26 04:47