娱记八卦:这个关于指针的程序为什么在tc2.0下不能正确输出结果?

来源:百度文库 编辑:高校问答 时间:2024/04/28 11:22:38
下面这个程序在tc下输出的内存地址是混乱的,不符合数组存储的规则,但用一些比较新的编辑器就可以正确显示结果
这是为什么??是跟我的操作系统有关吗?
ps:系统windows xp
#include<stdio.h>

int ctr;
short array_s[10];
float array_f[10];
double array_d[10];

int main(void)
{
printf( "\n\t\tShort\t\tFloat\t\tDouble" );

printf( "\n===========================" );
printf( "=============================" );

/* Print the addresses of each array element. */

for ( ctr = 0; ctr < 10; ctr++)
printf( "\nElement %d:\t%ld\t\t%ld\t\t%ld", ctr+1,
&array_s[ctr], &array_f[ctr], &array_d[ctr] );
printf( "\n===========================" );
printf( "=============================" );

return 0;
}

输出地址的格式最好用%P